Search code examples
jsfjsf-2websphere

Websphere 8 cluster and JSF2 issue


I'm currently programming with JSF on Websphere 8.0 and am running into an issue and I think it's because of our clustering. We have two nodes and after one was down for some time, my problem was not occurring.

My problem is that my after submitting with through a commandButton ends in an javax.faces.application.ViewExpiredException.

Also in a stacktrace before this I found this:

View State cannot be reconstructed
javax.faces.FacesException: javax.faces.application.ViewExpiredException
    at org.apache.myfaces.shared_impl.util.StateUtils.decrypt(StateUtils.java:496)
    at org.apache.myfaces.shared_impl.util.StateUtils.reconstruct(StateUtils.java:378)

So I guess there is something wrong with the handling between the two nodes.

In my web.xml I have set:

<distributable />

and

<env-entry>
        <env-entry-name>jsf/ClientSideSecretKey</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>SRe1FY2HKwBTOtT5KrtmiSoOzws+NA9/yX191wMFn9o=</env-entry-value>
    </env-entry> 

like some other mentioned in other threads, but my issue still remains.

Is there maybe some configuration to be made inside Websphere?


Solution

  • This points to an encryption issue. WebSphere 8.0 uses the MyFaces JSF 2.0 implementation - it's likely that you need to configure a shared secret for each of your nodes via the MyFaces context parameters. At minimum, you will need to set the org.apache.myfaces.SECRET parameter:

    <!-- Defines the secret (Base64 encoded) used to initialize the secret key
         for encryption algorithm. The size of it depends on the algorithm used for encryption -->
    <context-param>
        <param-name>org.apache.myfaces.SECRET</param-name>
        <param-value>MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIz</param-value>
    </context-param>
    

    An explanation of MyFaces security parameters is here.