Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

error in application when trying to convert date

Posted on 2014-01-24
6
Medium Priority
?
680 Views
Last Modified: 2014-01-26
Hello there,

I have this method which gets data from the db and sends it to the client. on one stage I am trying to convert the date from Gregorian to Persian date,but for some reason I get this error which I have attached below.

private DataProvider getSupplierOrderData(Long supplierorderid)
	{
		SupplierOrder supplierOrder = SupplierOrderBussinessLogic.getInstance().getSupplierOrderById(supplierorderid);
		List<SupplierOrderDetails> list = SupplierOrderDetailBussinessLogic.getInstance().getSupplierOrderDetailsFromsupplierOrder(supplierOrder);
		
		DataProviderBuilder dpb = new DataProviderBuilder();

        // add heading data
        dpb.add("so", supplierOrder.getSupplierOrderNo());
        dpb.add("sn", supplierOrder.getSupplier().getPerName());
        dpb.add("sec", supplierOrder.getSection().getAlternateName());
        
// I GET THE ERROR ON THIS BELOW LINE
        String date = CommonUtil.gregorianToJalali(supplierOrder.getSupplierOrderCreated()).toString();
        
        System.out.println("Document render date      !!!!      "+date);
        
        dpb.add("od", supplierOrder.getSupplierOrderCreated().toString());

        // add table data
        dpb.addJavaObject(list, "data");

        return dpb.getDataProvider();
	}

Open in new window


=========================================

ERROR I get is

java.lang.ExceptionInInitializerError
      at com.kaizen.erp.client.utill.CommonUtil.<clinit>(CommonUtil.java:17)
      at com.kaizen.erp.server.docmosis.SupplierOrderPrintController.getSupplierOrderData(SupplierOrderPrintController.java:138)
      at com.kaizen.erp.server.docmosis.SupplierOrderPrintController.handleRequest(SupplierOrderPrintController.java:64)
      at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:859)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:793)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
      at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:260)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:324)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code.  If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
      at com.google.gwt.core.shared.GWT.create(GWT.java:51)
      at com.google.gwt.core.client.GWT.create(GWT.java:85)
      at com.kaizen.erp.client.Kaizenerpweb.<clinit>(Kaizenerpweb.java:25)
      ... 30 more
[WARN] Nested in java.lang.ExceptionInInitializerError:
java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code.  If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
      at com.google.gwt.core.shared.GWT.create(GWT.java:51)
      at com.google.gwt.core.client.GWT.create(GWT.java:85)
      at com.kaizen.erp.client.Kaizenerpweb.<clinit>(Kaizenerpweb.java:25)
      at com.kaizen.erp.client.utill.CommonUtil.<clinit>(CommonUtil.java:17)
      at com.kaizen.erp.server.docmosis.SupplierOrderPrintController.getSupplierOrderData(SupplierOrderPrintController.java:138)
      at com.kaizen.erp.server.docmosis.SupplierOrderPrintController.handleRequest(SupplierOrderPrintController.java:64)
      at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:859)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:793)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
      at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:260)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:324)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
0
Comment
Question by:zolf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39808385
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
      at com.google.gwt.core.shared.GWT.create(GWT.java:51)
      at com.google.gwt.core.client.GWT.create(GWT.java:85)
     at com.kaizen.erp.client.Kaizenerpweb.<clinit>(Kaizenerpweb.java:25)

Note emphasis. It's clear from the stack trace that GWT.create is called from a ctor (Kaizenerpweb) and it looks pretty like server code to me.
0
 

Author Comment

by:zolf
ID: 39808501
thanks for your comments.so how can I resolve this issue.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39808512
Well, essentially by not doing what you're told not to do ;)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:zolf
ID: 39809651
sure I agree with that part,but can you tell me what I need to do to or the other way around to get to my requirement. by the way this code of mine is on the server,so what is the problem. how can I distinguish server code and client code.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 39809766
I can't advise really as i know nothing about your code. The error messages are generously explicit so you just need to make sure you act in accordance with what they tell you. So for instance any calls that they tell you should not be server side need to be removed
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39809894
:)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
A solution for Fortify Path Manipulation.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question