Search code examples
jsessionidprettyfaceswildfly-8

PrettyFaces fails in Wildfly 8.1.0 but works in 8.0.0


PrettyFaces kills the session on every request that involves a redirect when the application is deployed on Wildfly 8.1.0.Final. The same app deploys and works properly on Wildfly 8.0.0.Final.

On 8.1.0 PrettyFaces appears to prevent the servlet stack from retreiving the session ID.

The log shows no exceptions in either case. The URL rewrites occur, but session information (including login information) is gone. This is my pretty-config.xml

<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                  http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

<url-mapping id="user-settings">
    <pattern value="/protected/user/settings/"/>
    <view-id value="/protected/usersettings.xhtml"/>
</url-mapping>

<url-mapping id="thread-edit">
    <pattern value="/protected/threads/edit/#{stitchId}/" />
    <view-id value="/protected/threads/stitch.xhtml" />
    <action>#{stitchEditBean.editStitchFromId(stitchId)}</action>
</url-mapping>

<url-mapping id="threads-index">
    <pattern value="/protected/threads/" />
    <view-id value="/protected/threads/index.xhtml" />
</url-mapping>
</pretty-config>

The failure occurs for both PrettyFaces 2.0.12.Final and 3.0.0.Alpha2


Solution

  • As Ken noted, the underlying problem is related to https://issues.jboss.org/browse/WFLY-3448

    Adding an explicit cookie path to web.xml works around the issue and is safe.

    <session-config>
        <session-timeout>30</session-timeout>
        <cookie-config>
            <!--
            A bug in wildfly 8.1.0.final requires this path to be set explicitly or occasionally the default is
            incorrect and the system will generate one cookie per directory incorrectly.
            -->
            <path>/</path>
        </cookie-config>
    </session-config>
    

    You may have to manually clear the bad cookies in EACH directory of your app, or flush all your session cookies. Otherwise the old session cookies might hang around causing the issue.