• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

GWT IsSerializable,Serializable problem

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know you should only implement the IsSerializable interface, not IsSerializable and Serializable.
Are you using the java.util.List?
 
Bartender
Posts: 2348
102
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
salvin francis
Bartender
Posts: 2348
102
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So silly of me..
 
salvin francis
Bartender
Posts: 2348
102
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vish Shukla wrote: So silly of me..


happens...
we are human after all
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
salvin francis
Bartender
Posts: 2348
102
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author
Posts: 4112
28
Google Web Toolkit Eclipse IDE Flex
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!