0

I'm in the process of migrating from jsf1.1 to jsf2.0. When testing one of the jsf page that I've converted, it encountered the java.io.NotSerializableException on one of the class. I'm not getting this error when it was under jsf1.1. To resolve the problem, I added the Serializable interface to the class. After I did that I get the same error on a different class. I know I can simply add Serializable interface to this class to resolve the issue. But is this normal when migrating from jsf1.1 to jsf 2.0?

HockChai Lim
  • 1,331
  • 1
  • 13
  • 26
  • Have you changed the scope of some managed bean? – Pablo Oct 21 '13 at 16:38
  • It will be for `@SessionScoped` beans since the application server may serialize the session variables into disc. Note that this is a warning and not an error. – Luiggi Mendoza Oct 21 '13 at 16:39
  • Related: http://stackoverflow.com/q/3037722/1065197, http://stackoverflow.com/q/3851561/1065197, http://stackoverflow.com/q/18996151/1065197 and more: http://stackoverflow.com/search?tab=votes&q=%5bjsf%5d%20NotSerializableException%20is%3aquestion – Luiggi Mendoza Oct 21 '13 at 16:42
  • I didn't change the scope of the bean when converting it. It is configed in faces-config.xml with request scope. But the particular jsf page uses tomahawk saveState to achive the view scope that is not supported in jsf 1.1. I didn't make changes to this when converting to jsf 2.0. – HockChai Lim Oct 21 '13 at 16:57
  • Well then, remove the tomahawk saveState and mark your managed beans as `@ViewScoped`. Note that the questions I've posted in my last comment refers to similar problems. – Luiggi Mendoza Oct 21 '13 at 17:11
  • Follow this link http://stackoverflow.com/questions/4441713/migrating-from-jsf-1-2-to-jsf-2-0/21227775#21227775 – Pravin Jan 22 '14 at 05:30

2 Answers2

1

You're only getting this error now because in JSF 1.x, partial state saving wasn't a requirement. For a primer on JSF state saving, See this question.

From the JSF 2.x Spec:

For Applications versioned at 1.2 and under, the runtime must not use the partial state saving mechanism. For applications versioned at 2.0 and above, the runtime must use the partial state saving mechanism

This stipulation is what forces any and all view components to be serializable

Community
  • 1
  • 1
kolossus
  • 19,953
  • 3
  • 45
  • 94
0

Technically, anything stored in the session should be serializeable. In JSF, the view and flash scopes are stored within the session. So in short anything not in the request scope will end up in the session. However, you don't see the error until things are serialized out of the session. I don't know the details, but there msut be a difference in JSF 1.1 and JSF 2.0 implementations were JSF 2.0 is more aggressive at serializing the session.

pgreen2
  • 3,469
  • 3
  • 27
  • 53