Aquí está el escenario:
Currently we are working on running an application in a non-clustered environment. But right now we need to have an existing application be able to be deployed in a clustered weblogic environment.
This is a JSF based application and contains many managed beans. Now the problem is we do not have any clustered environment set up yet and is due to arrived in 3 weeks time.
In a weblogic cluster, I believe we are bound to encounter this problem
My question is, is there a way to find out which among my existing classes would fail in a clustered environment without having it deployed in a clustered environment.
I am not sure if there is a way to test if all member variables of a class is serializable so that it wont fail in a clustered environment.
preguntado el 09 de septiembre de 13 a las 04:09
When using Mojarra, you can use the following context param to tell it to always serialize the JSF state:
<context-param> <param-name>com.sun.faces.serializeServerState</param-name> <param-value>true</param-value> </context-param>
(MyFaces equivalent is
org.apache.myfaces.SERIALIZE_STATE_IN_SESSION, pero este valor predeterminado es
During testing, you'll get
NotSerializableException on instances which are not been marked
Serializable. Usually, it are the view and session scoped beans and all their properties which needs to be serializable.
Note that marking a property
transient is not the right solution, it would remain
null after deserialization (after restore view) which is just wrong. There are however certain cases where there is no other way (e.g. 3rd party API), in that case you'd better consider one of the following solutions:
Put property in a request scoped bean (you can always inject view/session scoped bean in there and delegate all form actions through it).
Lazily load the property. Example: Cambiar la solicitud para ver los resultados del alcance en java.io.NotSerializableException: javax.faces.model.ListDataModel
Wrap the class in a serializable class. Example: ¿Cómo hacer cookies persistentes con un DefaultHttpClient en Android?
As to business services, as long as you're using EJB or CDI, there's no need to mark business classes serializable. They're been injected as serializable proxies anyway.