1

Here's the scenario:

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.

Mark Estrada
  • 9,013
  • 37
  • 119
  • 186

1 Answers1

0

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, but this defaults to true already)

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.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555