File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResourceBundle Problem

 
Srikkanth Mohansundaram
Greenhorn
Posts: 16
AngularJS Chrome jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I ran into this problem , which i should call as a design problem. We had the resourcebundles saved in the session attributes based on the user locale.But when we moved to a clustered environment I found that resourcebundle wasn't serializable and I found tons of java.io.NotSerializableException.

I have 10 resourcebundles which I load on to the application context when the application is started using a ServletContextListener.Based on the user locale, i put the same in session.How should i do it?


Thanks,
Srikkanth
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check to be sure that every object bound to session (directly and indirectly) implements java.io.Serializable?
 
Srikkanth Mohansundaram
Greenhorn
Posts: 16
AngularJS Chrome jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

I didn't actually verify.But now i found that java.util.PropertyResourceBundle doesn't implement Serializable. We have a java.util.PropertyResourceBundle object added to the session, based on the locale.In all jsps we retrieve the object and do a getString(key) on the Resourcebundle object.Everything works fine, but we get exceptions in our logs.

com.vignette.portal.website.internal - WARNING! An attribute was set in the session that cannot serialize. Most application servers replicate the session using object serialization. java.util.PropertyResourceBundle@722a272b
java.io.NotSerializableException: java.util.PropertyResourceBundle
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java(Compiled Code)) An attribute was set in the session that cannot serialize. Most application servers replicate the session using object serialization. java.util.PropertyResourceBundle@722a272b
java.io.NotSerializableException: java.util.PropertyResourceBundle
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java(Compiled Code))


Thanks,
Srikkanth
 
Srikkanth Mohansundaram
Greenhorn
Posts: 16
AngularJS Chrome jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did i do a mistake by putting the resourcebundle in session?
Will ResourceBundle.getBundle(String name, Locale locale) in each JSP suffice?
Why java.util.PropertyResourceBundle doesn't implement Serializable, any specific reasons?
What is the general way to implement i18n in a web-app without any framework like struts/spring?

Thanks,
Srikkanth
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic