GWT Serialization Error (Missing Default Constructor)

Ever seen this error:
com.google.gwt.user.client.rpc.SerializationException: Type ‘your.class.Type’ 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.

Or this error:
Error: Type ‘your.class.Type’ was not serializable and has no concrete serializable subtypes

It can be caused by multiple reasons, but if you feel like you have done everything correctly (included source in GWT’s classpath during compilation, implement Serializable, google searched, prayed to the god of your choice) then you probably have the problem I had.  your.class.Type doesn’t have a default constructor.

So if your class has no default constructor (one that takes no arguments), add it and try again.  If that doesn’t fix it, and you find out what else is wrong, please post it as a comment here.

Also as an added bonus tip, when google searching for errors, your error usually is of the pattern: “something common to all errors of this type” “something specific to my project” “some more common stuff”.  Like in this error you have common stuff:
com.google.gwt.user.client.rpc.SerializationException: Type

Then specific stuff: 
‘your.class.Type’

Then more common stuff:
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.

The way to search for that is take your stuff and replace it with an asterisk (*) and put the whole thing in quotes and google will wildcard your specific stuff and you will get better results.  So a good way to search for this error would be (trimming because google only lets you search 32 words):
com.google.gwt.user.client.rpc.SerializationException: Type * was not included in the set of types which can be serialized by this SerializationPolicy”

Hope either of those things help someone.

 

78 Responses

  1. gwt dork Says:

    You saved my brain. Wasted 3 hours on this one. You make me suck less.

  2. fred Says:

    thank you so much!

  3. Milan Says:

    You helps me a lot. Tank you!

  4. Sammy Says:

    It does help me a lot, thanks, bro :)

  5. tan lei Says:

    Thanks !
    Thanks !
    Thanks !

  6. Cristian Says:

    Brother:

    I nonchalantly ignored the default constructor in the GXT examples I was browsing. I thought Darrell [Meyers] was just not knowing OO programming when he provided a default constructor for his class derived from BaseModelData.

    Moreover, when I saw the above error during compilation, and subsequently, my RPC answers weren’t received on the client side, the last thing in my mind was the default constructor.

    A long story short, I bow to you, Mr.

  7. Devin Says:

    Here’s another variant that’s only obvious in hindsight:

    GWT and non-GWT code exist in the same (eclipse) project in the same source tree. The GWT compiler reported problems with serialization of an interface (call it Schnib) that extends serializable. The only class that implemented this interface was a serializable POJO (call it SchnibImpl).

    Since the browser never (explicitly) created any of SchnibImpl objects, use of that class never showed up in the GWT part of the source tree; the GWT-visible code only referenced the Schnib interface. SchnibImpl itself existed outside of the part of the source tree that the GWT compiler was looking at.

    Adding in SchnibImpl to the path in the GWT xml file fixed it.

    *sigh*

    For the record, the GWT code continues to reference Schnib, not SchibImpl

  8. mattia Says:

    thanks a lot!! you solved my problem!! :)

  9. Cédric Says:

    Thank you so much !

  10. Thor Says:

    Yes! Thank you!

  11. akbrant Says:

    Holyjeez,

    I love it when its something simple!

    thanks
    thanks
    thanks

  12. Brian E Says:

    I have also found this error working with abstract classes. It appears that each subclass must also have null constructors. This is really confusing since the error only references the abstract class, not the subclasses.

  13. Muddasser Alam Says:

    You saved my day, thanks a million!!!!

  14. Rama Says:

    Man!!!! You are spot on! Thanks!!!

  15. Antoni Says:

    Even while doing all that you said, sometimes GWT still complains. Something that has helped me is to declare a private, unused variable of the type that GWT doesn’t want to Serialize, e.g.

    @SuppressWarnings(“unused”)
    private IssueClass _1;

    I put that declaration in any other GWT-serialized class.

  16. Andre Says:

    Had the same problem and spent almost a day to figure it out :-(
    A lot of details in GWT is not very logical and not very well documented.

    This issue I think “OK, it works by adding this default constructor, but WHY? Whats the logic behind it”.

    Guess there is some introspection code that assumes this, but by the error messages given is hard to figure this out.

    Tried to look at the full stacktrace in my case but there was no clue about any missing constructor.

  17. Koziołek Says:

    Thanks for this… I was missed default constructor but spent only 5 minutes in net and find yours solution.

  18. Chris Says:

    Thanks! I’m sure this one would have bit me in the butt for many hours if I didn’t find your post!!

  19. Nilesh Says:

    Thanks a lot.

  20. retha pasalli Says:

    Hi,

    I have checked my class and there has been a default constructor there but I still meet the same error. Can you help me? Thx

  21. retha pasalli Says:

    Hi holyjeez,

    sorry I didn’t put my error on my post before..

    Here is the error :
    Jun 18, 2009 8:18:06 AM org.apache.catalina.core.ApplicationContext log
    SEVERE: Exception while dispatching incoming RPC call
    com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:696)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:659)
    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 com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:529)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
    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.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    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: 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:678)
    … 27 more
    Caused by: com.google.gwt.user.client.rpc.SerializationException: Type ‘com.wii.integra.domain.ProgramStudi$$EnhancerByCGLIB$$52642e86′ 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.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)
    … 32 more

    And this is my ProgramStudi Serializable class :
    public class ProgramStudi implements IsSerializable {
    private static final long serialVersionUID = -1875269016855188318L;
    private long id;
    private String nama;
    private Fakultas fakultas;
    private String keterangan;

    public ProgramStudi(){}

    /**
    * @return the id
    */
    public long getId() {
    return id;
    }

    /**
    * @param id the id to set
    */
    public void setId(long id) {
    this.id = id;
    }

    /**
    * @return the nama
    */
    public String getNama() {
    return nama;
    }

    /**
    * @param nama the nama to set
    */
    public void setNama(String nama) {
    this.nama = nama;
    }

    /**
    * @return the fakultas
    */
    public Fakultas getFakultas() {
    return fakultas;
    }

    /**
    * @param fakultas the fakultas to set
    */
    public void setFakultas(Fakultas fakultas) {
    this.fakultas = fakultas;
    }

    /**
    * @return the keterangan
    */
    public String getKeterangan() {
    return keterangan;
    }

    /**
    * @param keterangan the keterangan to set
    */
    public void setKeterangan(String keterangan) {
    this.keterangan = keterangan;
    }

    public boolean equals(Object obj)
    {
    if ((obj == null) ||
    (obj instanceof ProgramStudi == false))
    {
    return false;
    }
    else if (this == obj)
    {
    return true;
    }

    // ID comparison
    ProgramStudi progdi = (ProgramStudi) obj;
    return (id == progdi.getId());
    }

    And this is the mapping file (if it’s neccesary) :

    Thx before…
    Regards,
    Retha

  22. retha pasalli Says:

    Sorry I lost the mapping file :

  23. retha pasalli Says:

    [sourcecode]

    [/sourcecode]

  24. retha pasalli Says:

    <hibernate-mapping>
    <class name=”com.wii.integra.domain.Provinsi” table=”PROVINSI”>
    <id column=”PROVINSI_ID” name=”id”>
    <generator class=”native”/>
    </id>
    <property column=”NAMA” length=”150″ name=”nama” type=”string”/>
    <property column=”KETERANGAN” length=”200″ name=”keterangan” type=”string”/>
    </class>
    </hibernate-mapping>

  25. retha pasalli Says:

    kyaaaaa…sorry i put the wrong mapping file (I feel so stupid!!). Here is the right one :

    <hibernate-mapping>
    <class name=”com.wii.integra.domain.ProgramStudi” table=”PROGDI”>
    <id column=”PROGDI_ID” name=”id”>
    <generator class=”native”/>
    </id>
    <property column=”NAMA” length=”200″ name=”nama” type=”string”/>
    <property column=”KETERANGAN” length=”200″ name=”keterangan” type=”string”/>
    <many-to-one class=”com.wii.integra.domain.Fakultas” column=”FAKULTAS_ID” name=”fakultas”/>
    </class>
    </hibernate-mapping>

  26. retha pasalli Says:

    Hi…

    I just find the main problem..

    I added my HQL from this one :
    hqlQuery.append(“from CalonMahasiswa calon”);

    into :

    hqlQuery.append(“from CalonMahasiswa calon”); hqlQuery.append(” left join fetch calon.progdiPilihan progdi left join fetch progdi.fakultas”); hqlQuery.append(” left join fetch calon.provinsi”); hqlQuery.append(” left join fetch calon.kabKota”); hqlQuery.append(” left join fetch calon.tahunAjar”);

    And it works! Thanks for you who paid any attention or even replying my post..

  27. bugyboo Says:

    Thanks to you..

    It solved all my problems :)

  28. Anhtuan Says:

    Thanks a lot, You’ve solved my problem. 😀

  29. William Says:

    “Have you added the default constructor” they say. “But of course I ha…, waaaaait a minute…”

    Sigh…

    I should probably just hand in my keyboard before I do any more harm.

    Thanks man.

  30. Anuj Says:

    Dude, Thanks a lot for sharing this.

  31. Odeen Says:

    Thanks, I can’t help myself and started to laugth reading that of “if you belived you’ve done everything you can…. ”

    Thanks, it works for me, I forgot (once again, damm alzheimer) to create a default constructor.

  32. John Says:

    I have a related problem that I havent fix yet and do not completely understand.Please help me. Below are the details:

    public class EmployeeList extends LightEntity implements IsSerializable
    {
    private static final long serialVersionUID = 1L;

    private int emp_id;
    private String firstname;
    private String lastname;
    private double total_consumption;

    public EmployeeList()
    {

    }

    public EmployeeList(int emp_id, String firstname, String lastname,
    double total_consumption)
    {
    this.emp_id = emp_id;
    this.firstname = firstname;
    this.lastname = lastname;
    this.total_consumption = total_consumption;
    }

    public int getEmpID()
    {
    return emp_id;
    }

    public void setEmpID(int emp_id)
    {
    this.emp_id = emp_id;
    }

    public String getFirstname()
    {
    return firstname;
    }

    public void setFirstname(String firstname)
    {
    this.firstname = firstname;
    }

    public String getLastname()
    {
    return lastname;
    }

    public void setLastname(String lastname)
    {
    this.lastname = lastname;
    }

    public double getTotalConsumption()
    {
    return this.total_consumption;
    }

    public void setTotalConsumption(int total_consumption)
    {
    this.total_consumption = total_consumption;
    }
    }

    ERROR:

    [WARN] Exception while dispatching incoming RPC call
    com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:696)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:659)
    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.RPCCopy_GWT16.encodeResponse(RPCCopy_GWT16.java:597)
    at com.google.gwt.user.server.rpc.RPCCopy_GWT16.encodeResponseForSuccess(RPCCopy_GWT16.java:429)
    at com.google.gwt.user.server.rpc.RPCCopy.encodeResponseForSuccess(RPCCopy.java:193)
    at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:157)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
    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:205)
    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: java.lang.reflect.InvocationTargetException: null
    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:678)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:659)
    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.RPCCopy_GWT16.encodeResponse(RPCCopy_GWT16.java:597)
    at com.google.gwt.user.server.rpc.RPCCopy_GWT16.encodeResponseForSuccess(RPCCopy_GWT16.java:429)
    at com.google.gwt.user.server.rpc.RPCCopy.encodeResponseForSuccess(RPCCopy.java:193)
    at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:157)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
    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:205)
    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: Type ‘[Ljava.lang.Object;’ 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.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)
    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:678)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:659)
    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.RPCCopy_GWT16.encodeResponse(RPCCopy_GWT16.java:597)
    at com.google.gwt.user.server.rpc.RPCCopy_GWT16.encodeResponseForSuccess(RPCCopy_GWT16.java:429)
    at com.google.gwt.user.server.rpc.RPCCopy.encodeResponseForSuccess(RPCCopy.java:193)
    at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:157)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
    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:205)
    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)

  33. John Says:

    Additional info:

    In the Service Implementation class:

    @Override
    public List generateReport(String reportItem, String positionItem)
    {
    List employeeList =
    coDBManager.generateEmployeeReport(reportItem, positionItem);

    return employeeList;
    }

    In my DBManager class:

    public List generateEmployeeReport(String reportItem, String reportPosition)
    {

    Session session =
    MyHibernateUtil.getSessionFactory().getCurrentSession();

    session.beginTransaction();

    StringBuffer sql = new StringBuffer();
    sql.append(“select employee.emp_id, employee.lastname, employee.firstname, ” +
    “(select sum(itemdetails.amount) from Item item, ItemDetails itemdetails ” +
    “where item.emp_id=employee.emp_id and item.id = itemdetails.itemid) as total_consumption ” +
    “from Employee employee”);

    Query query = null;
    List result = null;

    try
    {
    query = session.createQuery(sql.toString());
    result = query.list();

    session.getTransaction().commit();
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }

    return result;
    }

  34. Kevin Says:

    Thank you! took me 5 hours to find this.

  35. lnr Says:

    Thank you so much !

  36. Ian Says:

    Muchas gracias

  37. amn Says:

    So my issue was not one of the above, but it was equally hard to diagnose. I have a class variable of type object as in:

    private Object myVariable;

    Apparently, GWT serialization does not like this, for the obvious reason that Object does not implement Serializable.

  38. Jogilein Says:

    Thanks!!! I thought I have to die… THANKS!!!

  39. An annoyed programmer Says:

    It bugs me when projects are this nit-picky. Why can’t this be done for me, or at least I be told of this somewhere? Either way, your solution worked, thanks.

  40. Chandan Says:

    I had the similar kind of problem, where I was returning a list of DTO objects.
    After adding the no-args constructor also, the same issue appeared.
    And after few investigation, I found a mistake, I had done in the code. If you are facing the same issue, please check whether you have added the DTO’s package in your .gwt.xml file.
    Something like this:

  41. Chandan Says:
  42. majo Says:

    THAAAAAAAAAAAAAANKS A LOT!

  43. Alex Says:

    This is pretty obvious if you know what you’re doing. All serializable objects need to have a default constructor. How else do you think the object is going to be constructed upon deserialization?

    However… I still have this problem despite

    a) having a default constructor
    b) adding the type as a subtype to an object used in a dummy GWT remote method.

    This GWT error completely sucks and whoever wrote it should be fired, and then shot. Who writes an error that says… oooh it could be this, or it could be this… may as well say “Error: Something is wrong. Figure it out yourself!”.

    I’d love to slap that google engineer around a bit.

  44. Bo Says:

    Priceless!

  45. Hermann Rangamana Says:

    In fact, the default constructor should be public. It does not work if you just put a default constructor with package visibility.
    Anyway, thanks alot!

  46. samamtha Says:

    Hi, any1 could help me here? i did what u said, adding a default constructor, but it doesnt work =( i need to submit my project next week…any1 please?

    ERROR

    SEVERE: WebModule[/WebApplication2]Exception while dispatching incoming RPC call
    com.google.gwt.user.server.rpc.UnexpectedException: Service method ‘public abstract java.util.ArrayList org.yournamehere.client.sampleservice.GWTService.myMethod()’ threw an unexpected exception: java.lang.NullPointerException
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:636)
    Caused by: java.lang.NullPointerException
    at org.yournamehere.client.sampleservice.CallMain.setCallee(CallMain.java:50)
    at org.yournamehere.server.sampleservice.GWTServiceImpl.myMethod(GWTServiceImpl.java:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
    … 29 more

    INFO: Loading application WebApplication2 at /WebApplication2
    INFO: WebApplication2 was successfully deployed in 2,879 milliseconds.
    SEVERE: WebModule[/WebApplication2]Exception while dispatching incoming RPC call
    com.google.gwt.user.server.rpc.UnexpectedException: Service method ‘public abstract java.util.ArrayList org.yournamehere.client.sampleservice.GWTService.myMethod()’ threw an unexpected exception: java.lang.NullPointerException
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:636)
    Caused by: java.lang.NullPointerException
    at org.yournamehere.client.sampleservice.CallMain.setCallee(CallMain.java:50)
    at org.yournamehere.server.sampleservice.GWTServiceImpl.myMethod(GWTServiceImpl.java:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
    … 29 more

    and this is my CallMain.java

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package org.yournamehere.client.sampleservice;

    import java.io.Serializable;
    import java.util.*;
    //import com.google.gwt.dev.util.collect.HashMap;
    //import com.google.gwt.user.client.rpc.IsSerializable;

    /**
    *
    * @author sc.wong
    */
    public class CallMain implements Serializable {

    public HashMap CallInfo;
    /**
    * HashMap that will always contain strings for both keys and values
    * @gwt.typeArgs
    */

    //default constructor
    public CallMain(){

    CallInfo = new HashMap();

    CallInfo.put(“Callee”,””);
    CallInfo.put(“Caller”,””);
    CallInfo.put(“Call_ID”,””);
    CallInfo.put(“Method”,””);
    CallInfo.put(“Time”, “”);
    }

    /*method used to set call_id
    * @param name call_id
    */
    public void setCall_ID(String call_id){
    CallInfo.put(“Call_ID”,call_id);
    }

    /*method used to set callee
    * @param name callee
    */
    public void setCallee(String callee){
    CallInfo.put(“Callee”,callee);
    }

    /*method used to set celler
    * @param name callee
    */
    public void setCaller(String caller){
    CallInfo.put(“Caller”,caller);
    }

    /*method used to set method
    * @param name method
    */
    public void setMethod(String method){
    CallInfo.put(“Method”,method);
    }

    /*method used to set time
    * @param name time
    */
    public void setTime(String time){
    CallInfo.put(“Time”,time);
    }

    /**
    * Method used to get Call_ID
    * @return Call_ID
    */
    public String getCall_ID() {
    return (String) CallInfo.get(“Call_ID”);
    }

    /**
    * Method used to get Caller
    * @return Caller
    */
    public String getCaller() {
    return (String) CallInfo.get(“Caller”);
    }

    /**
    * Method used to get Callee
    * @return Callee
    */
    public String getCallee() {
    return (String) CallInfo.get(“Callee”);
    }

    /**
    * Method used to get Method
    * @return Method
    */
    public String getMethod() {
    return (String) CallInfo.get(“Method”);
    }

    /**
    * Method used to get Time
    * @return Time
    */
    public String getTime() {
    return (String) CallInfo.get(“Time”);
    }
    }

    THANKS A LOT!

  47. Eddie Says:

    Thanks this issue has been driving me mad… super informative error message that one! Grrrrr

  48. Sunder Says:

    Thanks a ton!!! Nice troubleshooting.

  49. sempervivo Says:

    Thanks man. You saved me from a headache.

  50. tt Says:

    That’s a great hint. I would have never thought of that. Thanks a lot.

    By the way: it works (for me) even with a private default constructor, so you don’t expose any unwanted functionality.

  51. Damz Says:

    Thanks! it worked for me !

  52. zé felipe Says:

    mann thanks so much!!

  53. Nitish Says:

    Thanks! Helped! :)

  54. Krish Says:

    IOU :)

    Thanks a million!

  55. giuseppe Says:

    Same error with inner class … sigh!

  56. Douglas Tondo Says:

    thank you a lot!

  57. Dave Diamond Says:

    thanks very much for posting this — the title alone saved me!!

  58. Dave Tin Says:

    The Exception: com.google.gwt.user.client.rpc.SerializationException: Type ‘com.apple.business.object.fantasysport.Event’ 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.: instance = com.apple.business.object.fantasysport.Event@79efa

    Constructor:
    public Event() {

    }
    But still not …….

  59. Lizzy Says:

    Thank you SO MUCH!!!! You saved my weekend! :))

  60. aelgali Says:

    Thanks a lot for the tip. i totally missed the empty constructor part.

  61. Archana Says:

    Thanks a lot :)

  62. Basje Says:

    Thx, that error message is just plain evil. I wouldn’t want to pay the dev hours wasted on that one…

  63. Varun Vajpayee Says:

    You really helped me. Thank you!! you rock!

  64. Exceilence Says:

    Thanks, bro, you are.
    )))

    Crazy exception which does not tell us “TDO should implements Serializable”

  65. Benjamin Sautner Says:

    every once in a while i get this and find myself back at this blog trying to remember how i fixed it last time – hello to me if i’m back again – but another cause of this is having any fields declared as final in your Serializable – so make sure you don’t use final in your DTOs – GWT bug: http://code.google.com/p/google-web-toolkit/issues/detail?id=1054

  66. Jesus Says:

    Great.

    Didn’t see anything about default constructor in docs.
    Google documentation lacks a lot of info.

    thanks

  67. Ian Says:

    Thanks to Benjamin’s last comment there – GWT also can’t cope with anything that hasn’t been initialised, so make sure you’ve set you values to something – or null.

  68. gicu Says:

    thank you man. I knew that but I forgot about it :)

  69. Mike Sweeney Says:

    DEO GRATIAS. Default DTO had no default constructor.

  70. James Gao Says:

    Man! you realy save my life! I stuck on this error for a whole day!! You are brilliant!!!

  71. Jérôme Sengel Says:

    Thanks a lot you saved my friday !

  72. Amit Says:

    Love you brother :-)

  73. jrsinger Says:

    thanks! this helped!

  74. diskostu Says:

    That worked for me. Thanks!

  75. Abdelrahaman Aly Says:

    Thx Man!!!! You Are God!!!!

  76. MFarid Says:

    DAMN! IT WORKED!!!!

    thank youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

  77. Marcello Says:

    Saved my friday

  78. Joe Says:

    I’ve been a GWT’er for a few years now, but committed the sin of forgetting the no arg constructor, even though I could recite the RPC serialization requirements in my sleep.

    Thanks for bringing me a little bit of sanity today. :)

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.