Pruebas de serialización en el entorno agrupado de weblogic

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

java.io.NotSerializableException: 

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

1 Respuestas

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 true ya)

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:

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.

contestado el 23 de mayo de 17 a las 11:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.