1 Reply Latest reply on Oct 12, 2011 2:56 PM by Christian Sadilek

    "Double cannot be cast to Long" - demarshalling issue?

    slawek t Novice

      Hi,

       

      I have a bit strange issue and looks like wrong type conversion.

       

      UsersIdsDTO.java

       

      @ExposeEntity

      public class UsersIdsDTO implements Serializable {

       

          private static final long serialVersionUID = -5751561497655220118L;

            private List<Long> ids;

       

        public UsersIdsDTO( List<Long> ids ) {

              this.ids = ids;

          }

       

        public UsersIdsDTO( ) {

          }

       

        public List<Long> getIds( ) {

              return ids;

          }

       

      public void setIds( List<Long> ids ) {

              this.ids = ids;

          }

        }

       

       

      Server-side piece of code sending the message

       

      UsersIdsDTO deletedUsersIdsDTO = ...

      MessageBuilder.createMessage( ).toSubject( "deletedUsersNotification" ).with( "deletedUsersIdsDTO", deletedUsersIdsDTO )

                      .noErrorHandling( ).sendGlobalWith( dispatcher );

       

       

      Message receiver on Client side

       

              ErraiBus.get( ).subscribe( "deletedUsersNotification", new MessageCallback( ) {

       

                  @Override

                  public void callback( Message message ) {

                      UsersIdsDTO deletedUsersIdsDTO = message.get( UsersIdsDTO.class, "deletedUsersIdsDTO" );

                      List<Long> deletedUsersIds = deletedUsersIdsDTO.getIds( );

                      Long l = deletedUsersIds.get( 0 );    // the list contains elements

                      ...

                   }

              });

       

       

      The red line above causes the error:

       

      receiver 'deletedUsersNotification' threw an exception
      Additional details:

      deletedUsersIdsDTOcom.company.proj.shared.service.rpc.dto.UsersIdsDTO@103f732
      ToSubjectdeletedUsersNotification

       

      java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Long
        com.company.proj.client.activity.UsersActivity$2.callback(UsersActivity.java:128)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl$3.callback(ClientMessageBusImpl.java:239)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke(Method.java:601)
        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:172)
        com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
        com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
        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:1211)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1208)
        org.jboss.errai.bus.client.framework.ClientMessageBusImpl$5.onResponseReceived(ClientMessageBusImpl.java:534)
        com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
        com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
        sun.reflect.GeneratedMethodAccessor166.invoke(Unknown Source)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke(Method.java:601)
        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:172)
        com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
        com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        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:213)
        sun.reflect.GeneratedMethodAccessor165.invoke(Unknown Source)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke(Method.java:601)
        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:172)
        com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
        com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        java.lang.Thread.run(Thread.java:722)

       

       

      What's wrong and how to solve it?