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

ResourceBundle Problem

Srikkanth Mohan
Greenhorn

Joined: Apr 10, 2008
Posts: 5
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

Joined: Dec 11, 2004
Posts: 13410

Did you check to be sure that every object bound to session (directly and indirectly) implements java.io.Serializable?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Srikkanth Mohan
Greenhorn

Joined: Apr 10, 2008
Posts: 5
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 Mohan
Greenhorn

Joined: Apr 10, 2008
Posts: 5
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
 
wood burning stoves
 
subject: ResourceBundle Problem
 
Similar Threads
Strange ServletContext behavior
SCEA Question about ResourceBundle: What is your answer?
Constants Class
"Standard" way to use ResourceBundles
Custom ResourceBundles