Solved

error in application when trying to convert date

Posted on 2014-01-24
6
659 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now