Solved

error in application when trying to convert date

Posted on 2014-01-24
6
668 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
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

696 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