Another idea from looking over your exception again:

Since you are loading an object with references to other objects you
also would want to make sure that hibernate really loads the
references. I think by default it uses lazy fetching and hence
initializes the references with proxy objects. These proxy objects
again are not serializable by GWT (by itself). You can deactivate lazy
fetching in the hibernate mapping file:

<hibernate-mapping package="my.package" default-lazy="false">

This makes hibernate really load and instantiate a Category object and
not a proxy.

Andreas

On 8 Jul., 12:13, andreas <[email protected]> wrote:
> I had a similar problem once.
>
> You could sysou the rtnAryList.class to make sure it really is an
> instance of ArrayList and not a collection of hibernate. Although you
> instantiate an ArrayList the parsed call to list() may return
> something different. If it is one of hibernates collections (which it
> uses for lazy fetching and so on afaik) you could "manually" add all
> entries in an instance of ArrayList.
>
> The hibernate collections are not serializable by GWT by default. I
> think there is also at least one project out there for integrating
> hibernate to GWT which also avoids this problem, you might want to
> give it a quick search.
>
> Andreas
>
> On 8 Jul., 11:56, Ho Jimmy <[email protected]> wrote:
>
>
>
> > Hi,
>
> > I keep getting the serialization exception and causing the rpc failed. Can
> > someone tell me what's going on?
>
> >  com.google.gwt.user.client.rpc.SerializationException: Type
> > 'com.jobscout.frontpage.client.Category$$EnhancerByCGLIB$$424f9bbb' 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.jobscout.frontpage.client.categ...@9cdbbc
>
> > I use hibernate to extract the records, put the result in the ArrayList. To
> > test the serialization, I dropped the hibernate part and built the ArrayList
> > of the type in the Impl and it works. So, I am not sure how the hibernate
> > return the arraylist<type> causes the serialization exception.
>
> > The following are extracted from my code that is relevent.
>
> > public class Job implements Serializable {
> >  private long oid;
> >  private long acctOid;
> >  private String subject;
> >  private String description;
> >  private Category category;            //Serializable
> >  private SubCat1 subcat1;            //Serializable
> >  private Mesgtype mesgtype;            //Serializable
>
> > This part is the testing and it works. I create the Arraylist instead of
> > using hibernate to extract records and return an Arraylist.
>
> >  public ArrayList<Job> getJobAryLstTest(){
> >   ArrayList<Job> jobarylst = new ArrayList<Job>();
> >   Category catparttime = new Category(0,"Parttime");
> >   SubCat1 painter = new SubCat1(0, catparttime,"Partime Painter");
> >   Mesgtype postjobmesgtype = new Mesgtype(0, "Post Job");
> >   Job job1 = new Job(0,"subject1","descruotuib1",catparttime,
> > painter,postjobmesgtype);
> >   Job job2 = new Job(0,"subject2","descruotuib2",catparttime,
> > painter,postjobmesgtype);
> >   jobarylst.add(job1);
> >   jobarylst.add(job2);
> >   return jobarylst;
>
> > This part call the hibernate dao and cause serialization exception
> >  public ArrayList<Job> getAllJobAryLst() {
> >   JobDAO jobdao=new JobDAO();
> >   ArrayList<Job> rtnJobList;
> >   rtnJobList = jobdao.getAllJob();
> >   return rtnJobList;
> >  }
>
> > This part is the DAO
> >  public ArrayList<Job> getAllJob()
> >  {
> >   ArrayList<Job> rtnAryList=new ArrayList<Job>();
> >   try
> >   {
> >    if(!session.isOpen())
> >    {
> >     session = HibernateUtil.getSessionFactory().openSession();
> >    }
> >    session.beginTransaction();
> >    String hql="from Job job";
> >    rtnAryList = (ArrayList<Job>)session.createQuery(hql).list();
> >    return rtnAryList;
> >   }
> >   catch(Exception e)
> >   {
> >    System.out.println(e.toString());
> >    return null;
> >   }
> >  }
>
> > Thanks
> > Jimmy

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to