Question

i am working on social website, and i am using JSF 2.2 and i have some beans with view scopes in those beans services are injected.

i am getting the famous NotSerializableException sometimes in tomcat and i have some questions:

1- what are the disadvantages of disabling session persistence by using empty manager as follows:

<Context ... >
    <Manager pathname="" />
</Context>

and when to use this approach ?

2- if i am going with implementing Serializable interface, should i make view scopes (what about request and session beans ?) only implements the Serializable interface and therefore mark the injected services as transient ?

3- is the beans the only layer that should implement Serializable and services and daos shouldn't ? and what are the disadvantages of implementing Serializable for services or daos ?

please advise.

Était-ce utile?

La solution

1- what are the disadvantages of disabling session persistence by using empty manager as follows:

<Context ... >
    <Manager pathname="" />
</Context>

The disadvantage is that you don't get session persistence.

and when to use this approach ?

When you don't want session persistence.

2- if i am going with implementing Serializable interface, should i make view scopes (what about request and session beans ?) only implements the Serializable interface and therefore mark the injected services as transient ?

You need to make anything that can be bound into a Session serializable, and its non-static non-transient members, and so on recursively until closure. The NotSerializableExceptions will tell you when you've missed something.

3- is the beans the only layer that should implement Serializable and services and daos shouldn't

Correct. Serializing services doesn't make sense, and DAOs ditto, so they need to be transient when members.

? and what are the disadvantages of implementing Serializable for services or daos ?

See above. For services it's basically impossible; for DAOs you have a major liveness problem. DAOs should be extremely transient as well as transient.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top