File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes GWT and the fly likes GWT IsSerializable,Serializable problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "GWT IsSerializable,Serializable problem" Watch "GWT IsSerializable,Serializable problem" New topic
Author

GWT IsSerializable,Serializable problem

Sanket L Shah
Ranch Hand

Joined: May 08, 2009
Posts: 49
Hi all,

i am developing on application in GWT.

Whenever I am trying to put logged in user in to HttpSession it throws exception like...

com.google.gwt.user.client.rpc.SerializationException: Type 'org.hibernate.collection.PersistentBag' 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.


My User Class is so simple




please help me out....
Frank Dijkstra
Greenhorn

Joined: Dec 09, 2009
Posts: 6
As far as I know you should only implement the IsSerializable interface, not IsSerializable and Serializable.
Are you using the java.util.List?
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

when using hibernate with GWT,

you would require 2 beans instead of one....

1. bean that would be persisted in database
2. bean that would be sent across the network for use in gwt

People call these with various names such as DTOs [Data Transfer Objects] and TOs [Transfer objects], etc...

I know these are a bit redundant, but that's the way these work...

check the following links:
http://www.rbgrn.net/content/32-using-hibernate-google-web-toolkit-gwt
http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Even its comfortable to use Hibernate along with GWT with only one set of beans. To do this, you need create one converter which will remove all the uninitialized proxies from beans before beans are transfered from the server to client. In this approach, before sending beans back to the client(Browser), you need to send the beans to Conversion layer.

Gilead will be helpful for achieving this.

Thanks & Regards,
Vishal S Shukla (SCJP 93%, SCWCD 94%, SCBCD 100%)
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Hi Vish,
Thats a wonderful piece of information,
The link posted should have been http://noon.gilead.free.fr/gilead/
instead of http://www.Gilead.com which leads to a (nicely designed) pharmaceutical company website.

In our company too we use two classes: one for database one for transferring across the web.


If the OP wants to do it the traditional way, here is a very detailed tutorial that explains the process step by step:
http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html

This url was also mentioned in my previous post
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
So silly of me..
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Vish Shukla wrote: So silly of me..

happens...
we are human after all
Suhas Bilaye
Ranch Hand

Joined: Sep 10, 2009
Posts: 80
Hi,

I have used GWT with hibernate. But I have not used any other external jar. I have my POJO implement the Serializable interface and its the same object that is being used on the gwt client as well as hibernate.. I haven't used any convertor as well though it might be a better way as you don't want to share the same pojo between the client and the server.

There is a possibility that you have a class which implements Serializable and you have an attribute field within that class which is not Serializable hence you might be getting this exception.

Regards,
Suhas


Thanks and Regards,
Suhas
http://www.xplore-java.blogspot.com/
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Suhas Bilaye,
you need to read the posts before posting a reply.

in the url i have mentioned, there is no need to have an external jar,

btw have you tried to return a collection of objects ?

You need to have two pojos not one.
Suhas Bilaye
Ranch Hand

Joined: Sep 10, 2009
Posts: 80
salvin francis,

I have gone through the posts and the url as well but i have stated my personal experience. It has nothing to do with what was mentioned in the url. If you see my post,
it clearly states
But I have not used any other external jar
.

btw have you tried to return a collection of objects ?

Yes I have tried sending a collection of objects from server to GWT client. It works fine.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

I remember reading documentation that said GWT will treat Java Serializable identically to GWT IsSerializable. In other words, if you have a bunch of existing Java classes that implement Serializable, you don't need to go back and add IsSerializable to them.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GWT IsSerializable,Serializable problem