0

I have a JSF and Spring integrated application. My Account Backing Bean class is with scope session and it is Serializable [as suggested here] . In my web.xml javax.faces.STATE_SAVING_METHOD value is ‘server’. Everything works good still here.

[I have Backing bean, Service class and DAO class in layers.]

When I change the value of javax.faces.STATE_SAVING_METHOD to ‘client’ the application throws exception ‘java.io.NotSerializableException’ pointing to my service class. If I make the service class Serializable then the ‘java.io.NotSerializableException’ points to my DAO class. If I make the DAO class Serializable the application will work without issues.

However I think making the service class and DAO class Serializable is a not a good approach.

Looking for expert opinion.

Thanks in advance.

Community
  • 1
  • 1
Sam
  • 554
  • 1
  • 12
  • 23

1 Answers1

-1

You should mark your service as transient in your account backing bean. This prevents serialization.

Example:

@RequestScoped
public class AccountBackingBean {

 @EJB
 private transient MyService myService;
 private String someValue;

}

See also:

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • Poor example. EJBs are by default injected as serializable proxies. OP clearly isn't using EJB. And, how would you revive the service after deserialization? NPE would occur on any attempt to access the service. – BalusC Sep 10 '14 at 10:00