Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid.getAttributeAsDate() not returning a serializable java.util.Date

    Using smartgwt3.0p nightly build, starting around 10/25 of this year, the ListGrid method getAttributeAsDate() is no longer returning a serializable java.util.Date object. This is breaking all our objects being serialized back to the server. Is there a reason why this was added? Is there an alternative method that will be added to get the java.util.Date object for backward compatibility? We are surprised that a nightly build of smartgwt 3.0 contains changed signatures of this type.

    #2
    There doesn't appear to have been a signature change here..

    Did you really mean ListGrid.getAttributeAsDate(), or did you actually mean Record.getAttributeAsDate()?

    If on a ListGrid, what attribute are you accessing?

    When you say it is "no longer returning a serializable java.util.Date object", do you mean that it returns null, or something else?

    Comment


      #3
      Sorry, to be more specific in the base class down the hierarchy of ListGridRecord -> Record -> RefDataClass -> DataClass the method getAttributeAsDate() returns the results from calling the method JSOHelper.getAttributeAsDate(jsObj, property); It is this method as shown below that is causing the problem.

      public static native Date getAttributeAsDate(JavaScriptObject elem, String attr) /*-{
      var jsD = elem[attr];
      if (jsD == null || jsD === undefined) {
      return null;
      } else {
      var ret;
      if (jsD.logicalDate) {
      ret = @com.smartgwt.client.util.LogicalDate::new(D)(jsD.getTime());
      } else if (jsD.logicalTime) {
      ret = @com.smartgwt.client.util.LogicalTime::new(D)(jsD.getTime());
      } else {
      ret = @com.smartgwt.client.util.JSOHelper::toDate(D)(jsD.getTime());
      }
      return ret;
      }
      }-*/;

      Comment


        #4
        OK, can you answer the other questions - what exactly is being returned and how does it differ?

        Perhaps the problem is that LogicalDate (a trivial subclass of Date) is not recognized as serializable in some downstream code you've got?

        Comment


          #5
          Yes, I meant to say Record.getAttributeAsDate().

          No, its not returning null, it returns a LogicalDate object instead of a Date object. It looks like the LogicalDate class was added sometime after 10/25/12 and was not present before this in the 3.0 codestream.

          This instance of LogicalDate does not seem to be getting serialized properly where java.util.Date was. Again, this breaks a whole multitude of our service calls. I would hope that this method being in the same release number would continue to return the same data type.

          Comment


            #6
            Again, LogicalDate is a trivial subclass of Date, in Java parlance it is an instanceof Date.

            It also does not have any behavior differences relative to Date.

            You should look into how this could possibly break your downstream code, as it suggests that someone has written some naive code that does something like obj.getClass().getName().equals("java.util.Date") to detect Dates whereas an instanceof check should have been used instead. If this kind of thing is the cause, then the same code would break with any subclass of Date, which is common usage in Java.

            Let us know if we can help; as of now, as there was no signature change or behavior change, we don't plan to reverse this bugfix.

            Comment


              #7
              I have same or similar problem.
              GWT is throwing exception:

              Code:
              com.google.gwt.user.client.rpc.SerializationException
              since method:

              Code:
              com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.getObjectTypeSignature
              for LogicalDate is returning null when it tries to serialize LogicalDate object.

              Looking deeper it turns out inside object:

              Code:
              com.google.gwt.user.client.rpc.impl.SerializerBase
              map:

              Code:
              Map<String, String> signatureMapJava
              does not contain:

              Code:
              com.smartgwt.client.util.LogicalDate
              so this call returns null:

              Code:
              signatureMapJava.get(clazz.getName());
              Any help is welcome.
              BR
              Marije

              Comment


                #8
                Can you clarify how this arises - presumably you are using a GWT-RPC service? If so, it seems like your RPC service is not regarding LogicalDate as serializable but by the basic rules of Java, it clearly is serializable.

                So is the problem possibly that you need to run a new GWT compile and/or clear your GWT unitcache?

                Comment


                  #9
                  Thanks for reply.
                  Yes, I am using GWT-RPC.
                  I have tried to clean and GWT compile project but it does not help.

                  Any other suggestion?

                  Thanks.
                  BR
                  Marije

                  Comment


                    #10
                    Maybe problem is in missing default constructor for LogicalDate,
                    e.g. maybe you are missing:

                    Code:
                    	private LogicalDate() {
                    		super();
                    	}
                    Thanks.
                    BR
                    Marije

                    Comment


                      #11
                      We've added the private constructors in all branches where LogicalDate/LogicalTime exists.

                      Thanks for letting us know it was GWT-RPC that was choking, that was probably the other user's issue as well.

                      It would be great if you can confirm this fixes the issue for you.

                      Comment


                        #12
                        Hi,
                        well it is better but still not working.
                        I am getting following exception:
                        Code:
                           [WARN] saporderServlet: An IncompatibleRemoteServiceException was thrown while processing this call.
                        com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: java.lang.NumberFormatException: Expected type 'int' but received a non-numerical value: TqXrXRb
                        	at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:323)
                        	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:206)
                        	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
                        	at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
                        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                        	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.handle(ServletHandler.java:362)
                        	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.content(HttpConnection.java:843)
                        	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
                        	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: com.google.gwt.user.client.rpc.SerializationException: java.lang.NumberFormatException: Expected type 'int' but received a non-numerical value: TqXrXRb
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserialize(ServerSerializationStreamReader.java:689)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readObject(ServerSerializationStreamReader.java:567)
                        	at com.google.gwt.user.server.rpc.core.java.util.Collection_ServerCustomFieldSerializerBase.deserialize(Collection_ServerCustomFieldSerializerBase.java:38)
                        	at com.google.gwt.user.server.rpc.core.java.util.ArrayList_ServerCustomFieldSerializer.deserialize(ArrayList_ServerCustomFieldSerializer.java:40)
                        	at com.google.gwt.user.server.rpc.core.java.util.ArrayList_ServerCustomFieldSerializer.deserializeInstance(ArrayList_ServerCustomFieldSerializer.java:54)
                        	at com.google.gwt.user.server.rpc.core.java.util.ArrayList_ServerCustomFieldSerializer.deserializeInstance(ArrayList_ServerCustomFieldSerializer.java:33)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeImpl(ServerSerializationStreamReader.java:859)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserialize(ServerSerializationStreamReader.java:662)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readObject(ServerSerializationStreamReader.java:567)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader$ValueReader$8.readValue(ServerSerializationStreamReader.java:140)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeValue(ServerSerializationStreamReader.java:425)
                        	at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:312)
                        	... 22 more
                        Caused by: java.lang.NumberFormatException: Expected type 'int' but received a non-numerical value: TqXrXRb
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.getNumberFormatException(ServerSerializationStreamReader.java:999)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readInt(ServerSerializationStreamReader.java:537)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readObject(ServerSerializationStreamReader.java:552)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader$ValueReader$8.readValue(ServerSerializationStreamReader.java:140)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeValue(ServerSerializationStreamReader.java:425)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeClass(ServerSerializationStreamReader.java:807)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeImpl(ServerSerializationStreamReader.java:878)
                        	at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserialize(ServerSerializationStreamReader.java:662)
                        	... 33 more
                        com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: java.lang.NumberFormatException: Expected type 'int' but received a non-numerical value: TqXrXRb
                        	at com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException_FieldSerializer.instantiate(IncompatibleRemoteServiceException_FieldSerializer.java:16)
                        	at com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException_FieldSerializer.create(IncompatibleRemoteServiceException_FieldSerializer.java:25)
                        	at com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:115)
                        	at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:396)
                        	at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
                        	at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
                        	at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
                        	at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
                        	at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
                        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                        	at java.lang.reflect.Method.invoke(Unknown Source)
                        	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                        	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                        	at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                        	at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
                        	at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
                        	at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                        	at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
                        	at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
                        	at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                        	at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                        	at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
                        	at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
                        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                        	at java.lang.reflect.Method.invoke(Unknown Source)
                        	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                        	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                        	at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                        	at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
                        	at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
                        	at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
                        	at java.lang.Thread.run(Unknown Source)
                        .

                        Is this indicative for you or you want more traces?
                        Thanks.
                        BR
                        Marije

                        Comment


                          #13
                          Have you already cleared our your GWT unitcache and re-run a GWT compile? This just looks like staleness.

                          Comment


                            #14
                            I have tried all kinds of clear and GWT compiles and nothing helps.
                            Until this issue is resolved I have introduced date conversion from LogicalDate to Date.
                            Thanks for help.
                            BR
                            Marije

                            Comment


                              #15
                              It turns out GWT-RPC just fails in general to serialize subclasses of date. We had to add custom serializers to work around this, and we've done so in 3.0p, 3.1d and 4.0d branches.

                              This might be a good one to add to the list of very good reasons not to use GWT-RPC.

                              Comment

                              Working...
                              X