6 Replies Latest reply on Dec 20, 2010 11:35 AM by Markus Dahm

    Mapping List<Date> in 1.1-Final

    Markus Dahm Novice

      Hi,

       

      I tried to create a RPC service that returns a list of dates (Mainly because GWT does not support Calendar...):

       

      @Remote
      public interface DateUtilService {
        List<Date> getDates(final String start, final String end);
      }

       

      But when I call this method I get a Class cast expection:

       

      java.lang.ClassCastException: java.lang.Double cannot be cast to java.util.Date
        de.akquinet.zalit.client.ProjectDateTable.getTableHeaders(ProjectDateTable.java:84)
        de.akquinet.zalit.client.ProjectDateTable.init(ProjectDateTable.java:27)
        de.akquinet.zalit.client.ZalitMainApplication$1$1.callback(ZalitMainApplication.java:61)
        de.akquinet.zalit.client.ZalitMainApplication$1$1.callback(ZalitMainApplication.java:1)
        org.jboss.errai.bus.client.api.builder.AbstractRemoteCallBuilder$1$1.callback(AbstractRemoteCallBuilder.java:107)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl$3.callback(ClientMessageBusImpl.java:223)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:597)
        com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
        com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714)
        com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
        com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
        com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl._store(ClientMessageBusImpl.java)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1128)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1125)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl$LongPollRequestCallback.onResponseReceived(ClientMessageBusImpl.java:888)
        com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
        com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393)
        sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:597)
        com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
        com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714)
        com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
        com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
        sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:597)
        com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
        com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669)
        com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
        com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        java.lang.Thread.run(Thread.java:662)

       

      The code at that point is when I iterate through that list:


        private List<String> getTableHeaders(final List<Date> dates) {
          final List<String> result = new ArrayList<String>();

       

          result.add("Projekt");

       

          for (final Date date : dates) {
            result.add(format(date));
          }

       

          return result;
        }

       

      My suspicion is that the complex Date type is mapped to Long during serialization, but not mapped back to a Date object correctly...?

       

      Cheers

        Markus

        • 1. Re: Mapping List<Date> in 1.1-Final
          Markus Dahm Novice

          Date[] does not work as well:

           


          Dismiss
          receiver 'de.akquinet.zalit.client.DateUtilService:RPC.getDates:java.lang.String:java.lang.String::RespondTo:1' threw an exception
          Additional details:
          Field    Value
          MethodReply    [1.2674844E12, 1.2675708E12, 1.2676572E12, 1.2677436E12, 1.26783E12, 1.2679164E12, 1.2680028E12, 1.2680892E12]
          ToSubject    de.akquinet.zalit.client.DateUtilService:RPC.getDates:java.lang.String:java.lang.String::RespondTo:1

           

          java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.util.Date;
            de.akquinet.zalit.client.ZalitMainApplication$3$1.callback(ZalitMainApplication.java:1)
            org.jboss.errai.bus.client.api.builder.AbstractRemoteCallBuilder$1$1.callback(AbstractRemoteCallBuilder.java:107)
            org.jboss.errai.bus.client.framework.ClientMessageBusImpl$3.callback(ClientMessageBusImpl.java:223)
            sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
            com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
            com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
            com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714)
            com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
            com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
            com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
            com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
            com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
            org.jboss.errai.bus.client.framework.ClientMessageBusImpl._store(ClientMessageBusImpl.java)
            org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1128)
            org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1125)
            org.jboss.errai.bus.client.framework.ClientMessageBusImpl$LongPollRequestCallback.onResponseReceived(ClientMessageBusImpl.java:888)
            com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
            com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393)
            sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
            com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
            com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
            com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714)
            com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
            com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
            com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
            com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
            com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
            com.google.gwt.core.client.impl.Impl.apply(Impl.java)
            com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
            sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
            com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
            com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
            com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669)
            com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
            com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
            java.lang.Thread.run(Thread.java:662)

          • 2. Re: Mapping List<Date> in 1.1-Final
            Mike Brock Master

            There wouldn't be some test code you can put together so I can create a unit test, would there?

            • 3. Re: Mapping List<Date> in 1.1-Final
              Markus Dahm Novice

              Here you are ...

               

              It also noticed that addPostInitTask does not seemed to be called sometimes...

              A lot of cleaning and rebuilding with eclipse and maven is required, quite fragile after all...

               

              Cheers

                markus

              • 5. Re: Mapping List<Date> in 1.1-Final
                Heiko Braun Master
                It also noticed that addPostInitTask does not seemed to be called sometimes...

                Can you elaborate on this?

                • 6. Re: Mapping List<Date> in 1.1-Final
                  Markus Dahm Novice

                  ... not in detail i'm afraid.

                  It may be caused by some inconsistent build. I'll tell you as soon as I can repeatedly reproduce this behavior....