Casting to wrong class during decoding rpc response.
misqu23 Sep 22, 2010 5:50 PMHi
I've got another problem with serialization, Here is the stack trace :
23:29:16.908 [ERROR] [basic] Failure decoding object java.lang.RuntimeException: could not demarshall type: pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment; value={"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"1987", "id":1, "active":true, "login":"admin", "password":"ISMvKXpXpadDiUoOSoAfww==", "userRoles":[{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserRole", "__ObjectID":"2", "id":1, "role":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.RoleType", "EnumStringValue":"USER"}, "selected":false, "deleted":false, "ownerGroup":null, "createDate":1285110213317, "createUser":null, "lastModifyDate":1285110213317, "lastModifyUser":null},{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserRole", "__ObjectID":"3", "id":2, "role":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.RoleType", "EnumStringValue":"ADMIN"}, "selected":false, "deleted":false, "ownerGroup":null, "createDate":1285110213322, "createUser":null, "lastModifyDate":1285110213322, "lastModifyUser":null}], "groups":[{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"2", "id":1, "name":"Scentia", "description":"Scentia", "groups":null, "parent":null, "users":null, "superGroup":true, "selected":false, "deleted":false, "ownerGroup":null, "createDate":1285110213015, "createUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}, "lastModifyDate":1285110213379, "lastModifyUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}}], "emails":null, "commonGroups":[], "superGroups":[{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}], "sourceUnit":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.OrganizationUnit", "__ObjectID":"3", "id":2, "unitType":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.UnitType", "EnumStringValue":"PERSON"}, "legalForm":null, "newsletter":false, "active":true, "description":null, "name":"Piotr", "fullName":"Nowak", "nip":null, "regon":null, "pesel":null, "birthDate":null, "addresses":null, "phones":null, "emails":null, "domains":null, "number":null, "selected":false, "deleted":false, "ownerGroup":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}, "createDate":1285110213263, "createUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}, "lastModifyDate":1285110213393, "lastModifyUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}}, "destinationUnit":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.OrganizationUnit", "__ObjectID":"2", "id":1, "unitType":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.UnitType", "EnumStringValue":"ORGANIZATION"}, "legalForm":null, "newsletter":false, "active":true, "description":null, "name":"Scentia", "fullName":"Scentia", "nip":null, "regon":null, "pesel":null, "birthDate":null, "addresses":null, "phones":null, "emails":null, "domains":null, "number":null, "selected":false, "deleted":false, "ownerGroup":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}, "createDate":1285110213253, "createUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}, "lastModifyDate":1285110213393, "lastModifyUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}}, "number":null, "selected":false, "deleted":false, "ownerGroup":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}, "createDate":1285110213253, "createUser":null, "lastModifyDate":1285110213253, "lastModifyUser":null}
23:29:16.908 [ERROR] [basic] Failure decoding object java.lang.RuntimeException: could not demarshall type: pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment; value={"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"1987", "id":1, "active":true, "login":"admin", "password":"ISMvKXpXpadDiUoOSoAfww==", "userRoles":[{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserRole", "__ObjectID":"2", "id":1, "role":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.RoleType", "EnumStringValue":"USER"}, "selected":false, "deleted":false, "ownerGroup":null, "createDate":1285110213317, "createUser":null, "lastModifyDate":1285110213317, "lastModifyUser":null},{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserRole", "__ObjectID":"3", "id":2, "role":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.RoleType", "EnumStringValue":"ADMIN"}, "selected":false, "deleted":false, "ownerGroup":null, "createDate":1285110213322, "createUser":null, "lastModifyDate":1285110213322, "lastModifyUser":null}], "groups":[{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"2", "id":1, "name":"Scentia", "description":"Scentia", "groups":null, "parent":null, "users":null, "superGroup":true, "selected":false, "deleted":false, "ownerGroup":null, "createDate":1285110213015, "createUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}, "lastModifyDate":1285110213379, "lastModifyUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}}], "emails":null, "commonGroups":[], "superGroups":[{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}], "sourceUnit":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.OrganizationUnit", "__ObjectID":"3", "id":2, "unitType":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.UnitType", "EnumStringValue":"PERSON"}, "legalForm":null, "newsletter":false, "active":true, "description":null, "name":"Piotr", "fullName":"Nowak", "nip":null, "regon":null, "pesel":null, "birthDate":null, "addresses":null, "phones":null, "emails":null, "domains":null, "number":null, "selected":false, "deleted":false, "ownerGroup":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}, "createDate":1285110213263, "createUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}, "lastModifyDate":1285110213393, "lastModifyUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}}, "destinationUnit":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.OrganizationUnit", "__ObjectID":"2", "id":1, "unitType":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.common.UnitType", "EnumStringValue":"ORGANIZATION"}, "legalForm":null, "newsletter":false, "active":true, "description":null, "name":"Scentia", "fullName":"Scentia", "nip":null, "regon":null, "pesel":null, "birthDate":null, "addresses":null, "phones":null, "emails":null, "domains":null, "number":null, "selected":false, "deleted":false, "ownerGroup":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}, "createDate":1285110213253, "createUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}, "lastModifyDate":1285110213393, "lastModifyUser":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.assignments.UserAssignment", "__ObjectID":"$1987"}}, "number":null, "selected":false, "deleted":false, "ownerGroup":{"__EncodedType":"pl.scentia.smartoffice.persistence.pojo.Group", "__ObjectID":"$2"}, "createDate":1285110213253, "createUser":null, "lastModifyDate":1285110213253, "lastModifyUser":null} at org.jboss.errai.bus.client.ext.ExtensionsLoaderImpl$45.demarshall(ExtensionsLoaderImpl.java:3186) at org.jboss.errai.bus.client.ext.ExtensionsLoaderImpl$45.demarshall(ExtensionsLoaderImpl.java:1) at org.jboss.errai.common.client.json.JSONDecoderCli.decodeObject(JSONDecoderCli.java:113) at org.jboss.errai.common.client.json.JSONDecoderCli._decode(JSONDecoderCli.java:80) at org.jboss.errai.common.client.json.JSONDecoderCli.decodeObject(JSONDecoderCli.java:129) at org.jboss.errai.common.client.json.JSONDecoderCli._decode(JSONDecoderCli.java:80) at org.jboss.errai.common.client.json.JSONDecoderCli.decode(JSONDecoderCli.java:62) at org.jboss.errai.bus.client.json.JSONUtilCli.decodeMap(JSONUtilCli.java:91) at org.jboss.errai.bus.client.json.JSONUtilCli.decodeCommandMessage(JSONUtilCli.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl._store(ClientMessageBusImpl.java) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1121) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1118) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl$LongPollRequestCallback.onResponseReceived(ClientMessageBusImpl.java:881) at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393) at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264) 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:188) at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.ClassCastException: pl.scentia.smartoffice.persistence.pojo.assignments.UserRole cannot be cast to pl.scentia.smartoffice.persistence.pojo.OrganizationUnit at org.jboss.errai.bus.client.ext.ExtensionsLoaderImpl$45.demarshall(ExtensionsLoaderImpl.java:3109) at org.jboss.errai.bus.client.ext.ExtensionsLoaderImpl$45.demarshall(ExtensionsLoaderImpl.java:1) at org.jboss.errai.common.client.json.JSONDecoderCli.decodeObject(JSONDecoderCli.java:113) at org.jboss.errai.common.client.json.JSONDecoderCli._decode(JSONDecoderCli.java:80) at org.jboss.errai.common.client.json.JSONDecoderCli.decodeObject(JSONDecoderCli.java:129) at org.jboss.errai.common.client.json.JSONDecoderCli._decode(JSONDecoderCli.java:80) at org.jboss.errai.common.client.json.JSONDecoderCli.decode(JSONDecoderCli.java:62) at org.jboss.errai.bus.client.json.JSONUtilCli.decodeMap(JSONUtilCli.java:91) at org.jboss.errai.bus.client.json.JSONUtilCli.decodeCommandMessage(JSONUtilCli.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl._store(ClientMessageBusImpl.java) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1121) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1118) at org.jboss.errai.bus.client.framework.ClientMessageBusImpl$LongPollRequestCallback.onResponseReceived(ClientMessageBusImpl.java:881) at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393) at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264) 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:188) at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:619)
It looks like during demarshalling of the object, being the response of the rpc call, errai tries to cast one of its member objects to the different class.
I have a testng test case which checks if encoding/decoding works well for my object graph using JSONEncoder and JSONDecoder. And
using JSONEncoder/Decoder works as expected so it seems like this problem lies on the client side.
If you need my entity classes I can post them.
If this is important, object returned by the rpc call has been cloned by gilead PersistentBeanManager.
BTW. Is there any way to inject HttpSession object into custom ModelAdapter object. I do need this because of using gilead InMemoryProxyStore is not a good idea.