title: com.google.gwt.user.client.rpc.SerializationException in Data Transfer Objects
body: <p>I am developing an application which interconnects GWT and Hibernate. From GWT server side I have the following code:</p>
  
  <pre><code>@Override
  public List&lt;AlarmDTO&gt; getAlarms() throws Exception{
      return deviceService.getAlarms();
  }
  </code></pre>
  
  <p>From Hibernate side, there is an Alarm class:</p>
  
  <pre><code>public List&lt;AlarmDTO&gt; getAlarms() {
      @SuppressWarnings("unchecked")
      List&lt;Alarm&gt; alarms = new ArrayList&lt;Alarm&gt;(DatabaseManager.createQuery("from Alarm"));
      List&lt;AlarmDTO&gt; alarmsDTOs = new ArrayList&lt;AlarmDTO&gt;(alarms != null ? alarms.size() : 0);
      if (alarms != null) {
          for (Alarm alarm : alarms) {
              String date = format.format(alarm.gettDate());
              alarmsDTOs.add(new AlarmDTO(alarm.getiAlarmId(),alarm.getsDescription(),alarm.getsCause(),date,alarm.iSetPointId,alarm.getiDeviceId()));
          }
      }
      return alarmsDTOs;
  }
  </code></pre>
  
  <p>It returns a List of AlarmDTO objects. This type of object is a Data Transfer Object. Its code is:</p>
  
  <pre><code>public class AlarmDTO implements Serializable{
    private static final long serialVersionUID = 1L;
    private int iAlarmId;
    private String sDescription;
    private String sCause;
    private String sDate;
    private int iSetPointId;
    private int iDeviceId;
  
    public AlarmDTO(){}
  
    public AlarmDTO(int iAlarmId,String sDescription,String sCause,String sDate,int iSetPointId,int iDeviceId){
      this.iAlarmId = iAlarmId;
      this.sDescription = sDescription;
      this.sCause = sCause;
      this.sDate = sDate;
      this.iSetPointId = iSetPointId;
      this.iDeviceId = iDeviceId;
    }
  }
  </code></pre>
  
  <p>However, when I run the application, it throws an exception com.google.gwt.user.client.rpc.SerializationException:</p>
  
  <pre><code>Exception while dispatching incoming RPC call
  com.google.gwt.user.client.rpc.SerializationException: Type 'com.cartif.dtos.EnergyDTO' 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.cartif.dtos.EnergyDTO@16b4be5
  at     com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:615)
  at     com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
  at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:45)
  at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:40)
  at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serializeInstance(ArrayList_CustomFieldSerializer.java:50)
  at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serializeInstance(ArrayList_CustomFieldSerializer.java:28)
  at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:736)
  at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:617)
  at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
  at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
  at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:535)
  at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
  at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:474)
  at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:571)
  at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
  at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
  at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
  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:726)
  at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
  at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
  at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
  at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
  at org.mortbay.jetty.Server.handle(Server.java:320)
  at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
  at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
  at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
  at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
  at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
  at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
  at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
  </code></pre>
  
  <p>I follow the same strategy with other objetcs and it works. I do not know why it does not run now. Could someone help me?</p>
  
  <p>Thanks!</p>