Menu

SerializationException

Help
2008-10-16
2013-04-19
  • Norman Maurer

    Norman Maurer - 2008-10-16

    Hi,

    when I try to load my a Entity over RPC I get an SerializationException. I have no clue why. What I'm missing ?

    I'm using Proxy mode...

    DomainObject:

    package de.heagmobilo.disponentscheduler.domain;

    import java.io.Serializable;

    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.Table;

    @Entity
    @Table(name = "USERS")
    public class User extends BaseEntity implements Serializable{
        /**
         *
         */
        private static final long serialVersionUID = -1662600123102634898L;
       
        private String password;
        private Role role;

        private String firstName;

        private String personalId;

        private String phoneNumber;

        private String cellNumber;

        /**
         * Return the Password
         *
         * @return password
         */
        @Column(name="PASSWORD", length=32, nullable=false)
        public String getPassword() {
            return password;
        }
       
        /**
         * Set the Password
         *
         * @param password
         */
        public void setPassword(String password) {
            this.password = password;
        }
       
        public void setRole(Role role) {
            this.role = role;
        }
       

        @ManyToOne
        @JoinColumn(name = "ROLE_ID")
        public Role getRole() {
            return role;
        }
       
        @Column(name="FIRST_NAME", length=32, nullable=false)
        public String getFirstName() {
            return firstName;
        }

    gwt.xml:

    <module>

          <!-- Inherit the core Web Toolkit stuff.                        -->
          <inherits name='com.google.gwt.user.User'/>
       
          <!-- Inherit the default GWT style sheet.  You can change       -->
          <!-- the theme of your GWT application by uncommenting          -->
          <!-- any one of the following lines.                            -->
          <inherits name='com.google.gwt.user.theme.standard.Standard'/>

          <!-- Other module inherits                                      -->
         <inherits name='com.extjs.gxt.ui.GXT'/> 
         <inherits name='net.sf.hibernate4gwt.Hibernate4Gwt15'/>
         <!-- Uncomment if your Domain class use JPA mapping annotations -->
         <inherits name='net.sf.hibernate4gwt.emul.java5.ejb3.Ejb3'/>
        
        
         <!-- Additional source path -->
         <source path='domain'/>
         <source path='client'/>
        
         <!-- Proxy generator -->
         <generate-with class="net.sf.hibernate4gwt.rebind.Gwt15ProxyGenerator">
             <when-type-assignable class="java.io.Serializable" />
         </generate-with>
        
          <!-- Specify the app entry point class.                         -->
          <entry-point class='de.heagmobilo.disponentscheduler.client.DisponentScheduler'/>
       
          <!-- Specify the application specific style sheet.              -->
      
          <stylesheet src='DisponentScheduler.css' />
       
    </module>

    Exception:
       
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }
       
        @Column(name="PERSONAL_ID", length=32, nullable=false)
        public String getPersonalId() {
            return personalId;
        }
       
        public void setPersonalId(String personalId) {
            this.personalId = personalId;
        }
       
        @Column(name="PHONE_NUMBER", length=32, nullable=true)
        public String getPhoneNumber() {
            return phoneNumber;
        }
       
        public void setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
        }

        @Column(name="CELL_NUMBER", length=32, nullable=true)
        public String getCellNumber() {
            return cellNumber;
        }
       
        public void setCellNumber(String cellNumber) {
            this.cellNumber = cellNumber;
        }
    }

    16.10.2008 12:44:33 org.apache.catalina.core.ApplicationContext log
    SCHWERWIEGEND: Exception while dispatching incoming RPC call
    java.lang.RuntimeException: com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
            at org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleExporterProcessingException(GWTRPCServiceExporter.java:344)
            at org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:313)
            at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
            at org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleRequest(GWTRPCServiceExporter.java:363)
            at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
            at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
            at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:686)
            at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:649)
            at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:583)
            at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
            at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:146)
            at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:520)
            at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:573)
            at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:441)
            at org.gwtwidgets.server.spring.hb4gwt.HB4GWTRPCServiceExporter.invokeMethodOnService(HB4GWTRPCServiceExporter.java:47)
            at org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:298)
            ... 21 more
    Caused by: java.lang.reflect.InvocationTargetException
            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.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:668)
            ... 30 more
    Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'de.heagmobilo.disponentscheduler.domain.User' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.  For security purposes, this type will not be serialized.
            at com.google.gwt.user.server.rpc.impl.LegacySerializationPolicy.validateSerialize(LegacySerializationPolicy.java:140)
            at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:581)
            at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
            at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:43)
            at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:36)
            ... 35 more

     
    • Bruno Marchesson

      Hi Norman,

      Looks like GWT issue, because of old LegacySerializationPolicy in stack trace.
      Your code looks right. Is the BaseEntity Serializable too ?

      Regards
      Bruno

      PS : maybe you should have a look at http://code.google.com/p/google-web-toolkit/issues/list?can=2&q=LegacySerializationPolicy&colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&cells=tiles

       
    • Norman Maurer

      Norman Maurer - 2008-10-16

      Hi Bruno.

      yeah BaseEntity implements Serializable ( its an abstract class). What makes me a bit wonder is that there is a *.rpc file which includes my Classes in the dir which contains the app. But the name is different..

      Any clue how this could happen ?

      Thx for your help...

       
    • Jippe Holwerda

      Jippe Holwerda - 2008-11-05

      Hi all,

      I seem to be having the same problem trying to serialize entities. I've tried the stateless mode as well as the proxy mode.
      The error I'm getting is:

      com.google.gwt.user.client.rpc.SerializationException: Type 'nl.forestfields.basedata.classificationtool.data.pojo.RecordType' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.  For security purposes, this type will not be serialized.
          at com.google.gwt.user.server.rpc.impl.LegacySerializationPolicy.validateSerialize(LegacySerializationPolicy.java:140)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:591)
          at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:146)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:530)
          at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:573)
          at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:441)
          at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:529)
          at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:477)
          at nl.forestfields.basedata.classificationtool.server.util.GwtRpcEndPointHandlerAdapter.processCall(GwtRpcEndPointHandlerAdapter.java:70)
          at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
          at nl.forestfields.basedata.classificationtool.server.util.GwtRpcEndPointHandlerAdapter.handle(GwtRpcEndPointHandlerAdapter.java:42)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
          at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
      ....
      ...
      ..

      I'm using GWT 1.5.2 and Hibernate4GWT 1.1.1.

      Is this a GWT issue because of the occurence of LegacySerializationPolicy in the stack trace? Should I bug them with this issue?

      Cheers,
      Jippe

       
      • Bruno Marchesson

        Hi,

        It looks like your service does not inherit from HibernateRemoteService instead of RemoteServiceServlet...

        Regards
        Bruno

         
    • Jippe Holwerda

      Jippe Holwerda - 2008-11-05

      Hi Bruno,

      My service code is as follows:

      @Controller
      @GwtRpcEndPoint
      public class HibernateSearchServiceImpl extends HibernateRemoteService implements SearchService {

          /**
           *
           */
          private static final long serialVersionUID = 6423936152621522221L;
         
          @Autowired
          private HibernateBeanManager beanManager;
         
          @Autowired
          private SearchManager searchManager;

          @Override
          public List<RecordType> searchRecordType(String searchText) {
              return searchManager.getRecordTypeByName(searchText);       
          }   
      }

      When I change my entity to extend from IsSerializable instead of Serializable it works correctly.

      Cheers,
      Jippe

       
    • Bruno Marchesson

      Hi,

      I see that you override the processCall method in nl.forestfields.basedata.classificationtool.server.util.GwtRpcEndPointHandlerAdapter class.
      HibernateRemoteService also overrides it.

      Can you post your processCall code to see if it can be the problem ?

      Regards
      Bruno

       
    • Jippe Holwerda

      Jippe Holwerda - 2008-11-05

      Below you can see the processCall implementation. It comes from http://blog.digitalascent.com/2007/11/gwt-rpc-with-spring-2x_12.html, and allows you to instantiate a GWT-RPC service like a normal Spring bean.

              @Override
          public String processCall(String payload) throws SerializationException {
              /*
               * The code below is borrowed from RemoteServiceServet.processCall, with
               * the following changes: 1) Changed object for decoding and invocation
               * to be the handler (versus the original 'this')
               */
              try {
                  RPCRequest rpcRequest = RPC.decodeRequest(payload, getCurrentHandler().getClass());

                  String retVal = RPC.invokeAndEncodeResponse(getCurrentHandler(), rpcRequest.getMethod(), rpcRequest.getParameters());

                  return retVal;

              } catch (final IncompatibleRemoteServiceException ex) {
                  getServletContext().log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex);
                  return RPC.encodeResponseForFailure(null, ex);
              }   
          }

      Cheers,
      Jippe

       
    • Bruno Marchesson

      Unfortunately, this code is not compatible with hibernate4gwt :-(
      Maybe you should have a look to GWT-SL library, wich allows you to call your GWT-RPC services like normal Spring beans. It includes a specific class (HB4GWTRpcServiceExporter) that integrates hibernate4gwt in the right way to allow both framework to work together.

      Regards
      Bruno

       
    • Jippe Holwerda

      Jippe Holwerda - 2008-11-05

      Ok, thanks for your time. I will look into GWT-SL.

      Cheers,
      Jippe

       
    • Jippe Holwerda

      Jippe Holwerda - 2008-11-06

      Hi Bruno,

      I've implemented GWT-SL instead of the custom handleradapter I had. However, now I'm getting a different error:

      Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'org.hibernate.collection.PersistentSet' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.
          at com.google.gwt.user.server.rpc.impl.StandardSerializationPolicy.validateSerialize(StandardSerializationPolicy.java:83)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:591)
          at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:146)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:530)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeClass(ServerSerializationStreamWriter.java:636)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:666)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:593)
          at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:146)
          at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:530)
          at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:573)
          at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:441)
          at org.gwtwidgets.server.spring.GWTRPCServiceExporter.invokeMethodOnService(GWTRPCServiceExporter.java:149)
          at org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:298)
          ... 21 more

      I've seen more people having this problem, but the solution is unclear to me.

      Cheers,
      Jippe

       
    • Jippe Holwerda

      Jippe Holwerda - 2008-11-06

      By the way, when I remove all attributes that use a Set from the RecordType entity, it works correctly.
      Do you have any idea Bruno?

      Cheers,
      Jippe

       
    • Bruno Marchesson

      Hi,

      You should use HB4GWTRpcServiceExporter instead of GWTRPCServiceExporter.

      Regards
      Bruno

       
    • Jippe Holwerda

      Jippe Holwerda - 2008-11-06

      Ah, I was using org.gwtwidgets.server.spring.GWTHandler. But apparently that doesn't work with HB4GWTRpcServiceExporter? Does this mean that for every service I want to export I will have to create a HB4GWTRpcServiceExporter with the service property set?

      Cheers,
      Jippe

       
    • - 2008-11-12

      I have exaclty the same problem.
      Iam using HB4GWTRpcServiceExporter.

      i have also no clue where so problem is ... obviously somewhere in the GWTRPCServiceExporter.

      Damn I dont want to dig myself into it :D

       
    • - 2008-11-12

      Iam not able to resolve this issue, due to my lack of knowlegde about the frameworks... sth is not working between the HB4GWTRpcServiceExporter and the GWTRPCServiceExporter of the GWT-SL

      I have tried a lot...
      activated loggin

      on server startup this have catched my eye:

      2008-11-12 17:38:22,854 [main] DEBUG org.gwtwidgets.server.spring.GWTHandler - Mapped URL path [/UserService.gwt] onto handler [org.gwtwidgets.server.spring.GWTRPCServiceExporter@8809ce]

      Shouldnt it be a HB4GWTRpcServiceExporter ??? due to the inheritance between them I am confused a bit.
      But it is looking like that the GWT-SL is the problem here.
      :(

      plz help!!!

       
    • - 2008-11-13

      okay after george give me some hint..

      i understand how to use GWT-SL with Hibernate4GWT. IT is really bad described on the GWT-SL page... missing such a lot of informations....

      here check this, like this it is working:

      first to use gwt-sl with hb4gwt. you need to change the urlmapping to a simple spring url handler.. the rest is shown in the example code of the gwt-sl page

      my task was to send a user to client... through all my services and than through the remoteserviceimpl

          <bean id="urlMapping"
              class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
              <property name="mappings">
                  <map>
                      <entry key="/UserService.gwt" value-ref="userHB4GWT" />
                  </map>
              </property>
          </bean>

          <bean id="userServiceRemoteImpl" class="org.fspmboard.server.rpc.UserServiceRemoteImpl">
              <property name="userService" ref="userService" />
          </bean>

          <bean id="userHB4GWT" class="org.gwtwidgets.server.spring.hb4gwt.HB4GWTRPCServiceExporter">
              <property name="beanManager" ref="hibernateBeanManager" />
              <property name="service" ref="userServiceRemoteImpl" />
              <property name="serviceInterfaces">
                  <value>
                      org.fspmboard.client.rpc.UserServiceRemote
                  </value>
              </property>
      </bean>

      this and REMOVING all inheritance from the UserServiceRemoteImpl NO extends of anything!!! this is the important fact. Just implements of the RemoteService...

      public class UserServiceRemoteImpl implements UserServiceRemote {}

      than it is workin, if you have any question i might be able to help.

       
      • Bruno Marchesson

        Hi,

        Many thanks for clarification. I will add it on Gilead web site.

        Regards
        Bruno

         
        • - 2008-11-13

          I'm glad i can help some other guys, who obviously have/had the same problems.

          Good that you will gonna add more hints for a proper configuration using hibernate4gwt/gilead with gwt-sl. I hope george will take my advice for updating/completing the doc of gwt-sl as well.

          regards

           
    • Daniele Renda

      Daniele Renda - 2008-11-25

      It's very strange, with the stateless mode all works fine.....

      Regards

      Daniele

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.