eclipse-ee4j / mojarra

Mojarra, a Jakarta Faces implementation
Other
159 stars 109 forks source link

JSF pages containing `#{session.id}` fail with NotSerializableException when sessions are distributable #5222

Closed pferraro closed 1 year ago

pferraro commented 1 year ago

Describe the bug

JSF pages containing #{session.id} fail with: java.io.NotSerializableException: com.sun.faces.cdi.SessionProducer$$Lambda$1586/0x0000000100cc6478 ... when deployed as a web application.

SessionProducer creates a SessionScoped bean using a non-serializable function, which naturally fails to serialize. I see nothing about this bean that should warrant it being SessionScoped rather than RequestScoped.

To Reproduce

A reproducer for this issue is available at: https://issues.redhat.com/browse/WFLY-17840

Expected behavior

#{session.foo} should behave the same as #{request.session.foo}.

Additional context

Changing #{session.foo} expressions to #{request.session.foo} sufficiently works around the issue. This resolves the expression via the RequestProducer, which, of course, is RequestScoped.