The error message means that you tried to send to the client a Category
that was actually an instance of a subclass of Category - one created by
Hibernate, and that subclass is not GWT-serializable (even if Category is).
You have to take the hibernate results and convert them to an object
that's free of the subclasses Hibernate builds. You might do this by
creating DTOs (some people use Dozer to build them). Gilead is designed
to do this automatically for you:
http://noon.gilead.free.fr/gilead/index.php?page=gwt
Paul
Ho Jimmy 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
> <mailto: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.
--
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.