Solved

error in application when trying to convert date

Posted on 2014-01-24
6
664 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
  • 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
Independent Software Vendors: 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 500 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate insert example 13 37
JAVA API design with micro service cloud in mind 1 75
Selenium docs api java index 3 64
Eclipse for Java EE development 2 43
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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.

685 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