Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

java.io.Serializable and HashMap

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

HashMap already implements Serializable It is not the problem.
Is your custom object serializable
 
Rainer Spruenken
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my object

 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
Can you also show us the full exception stack trace?
 
Rainer Spruenken
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And here is the error message

 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your Report under shared?
If yes, then I cannot help further than suggesting a full clean build
 
Rainer Spruenken
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the object it is not under shared...
 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, I will give it a try. Thanks a lot for your help. Regards Rainer
 
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thank you for the reply, I will try using the concrete types.

Regards Rainer
 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic