aspose file tools*
The moose likes GWT and the fly likes java.io.Serializable and HashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "java.io.Serializable and HashMap" Watch "java.io.Serializable and HashMap" New topic
Author

java.io.Serializable and HashMap

Rainer Spruenken
Greenhorn

Joined: Apr 11, 2012
Posts: 7
Hi all,

I need some help with serialization. In my app I use a custom object which contains HashMap<String, ArrayList<String>>.
When I try to tranfer this object to the server I get some serialization exception
(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 deserialized.)
I tried to use a custom field serializer without any luck.
The Problem is that I MUST use java.io.Serializable and cannot use IsSerializable which works fine. Is there a reliable way
to use java.io.Serializable with my HashMap?


Regards and Thanke Rainer
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Welcome to the Ranch.

HashMap already implements Serializable It is not the problem.
Is your custom object serializable


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rainer Spruenken
Greenhorn

Joined: Apr 11, 2012
Posts: 7
Thanks for your quick reply, can you please be clearer? I read a couple of threads about this topic and I think I get lost. My custom object consists of Strings, Boolean, Long and this HashMap. What do you think is wrong?

Rainer
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

What I meant was does your custom object implement serializable?
Let's make it easy. Show us your custom object code. (Don't forget to UseCodeTags though ;) )
Rainer Spruenken
Greenhorn

Joined: Apr 11, 2012
Posts: 7
Here is my object

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Thank you.
Can you also show us the full exception stack trace?
Rainer Spruenken
Greenhorn

Joined: Apr 11, 2012
Posts: 7
And here is the error message

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Is your Report under shared?
If yes, then I cannot help further than suggesting a full clean build
Rainer Spruenken
Greenhorn

Joined: Apr 11, 2012
Posts: 7
the object it is not under shared...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Aha!
/client - all your UI code goes here
/server - all your server code goes here
/shared - all your data code goes here

Just refactor under shared and you should be good

Rainer Spruenken
Greenhorn

Joined: Apr 11, 2012
Posts: 7
ok, I will give it a try. Thanks a lot for your help. Regards Rainer
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

Aha!
/client - all your UI code goes here
/server - all your server code goes here
/shared - all your data code goes here

Just refactor under shared and you should be good


Maneesh!! are you sure, this is going to make a difference. whatever you have written is a convention in my opinion (I strongly agree that we all should organize classes like this in a GWT application.)
Both the client and shared packages are on the GWT client side.
There is no any difference between the client & shared packages. please correct me if i am wrong.

Thanks


SCJP 5.0 SCWCD 5.0
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

Hi Rainer,

if the issue still persists, just change the Map to HashMap & List to ArrayList ( or any other implementer which you are using) and give it a try .
Providing concrete datatypes sometimes resolves the serialization issues and also enhances the performance.

Thanks
Rainer Spruenken
Greenhorn

Joined: Apr 11, 2012
Posts: 7
Hi, thank you for the reply, I will try using the concrete types.

Regards Rainer
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

avi sinha wrote:
Aha!
/client - all your UI code goes here
/server - all your server code goes here
/shared - all your data code goes here

Just refactor under shared and you should be good


Maneesh!! are you sure, this is going to make a difference. whatever you have written is a convention in my opinion (I strongly agree that we all should organize classes like this in a GWT application.)
Both the client and shared packages are on the GWT client side.
There is no any difference between the client & shared packages. please correct me if i am wrong.

Thanks


It is a convention and a good convention at that. Remember, anything (including UI and data) has to be Java<->JS translatable. By default, the GWT "compiler" is configured to pick everything under client and shared.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.io.Serializable and HashMap