Friday, August 30, 2013

Running a Stripes application in WildFly

When I tried to deploy a minimal web application that uses the Stripes Framework to the WildFly-8.0.0 application server, using the instructions given in the Stripes Wiki, I would always get this exception as soon as the first Strips action was requested:

17:23:17,452 ERROR [net.sourceforge.stripes.controller.StripesFilter] (default task-35) : net.sourceforge.stripes.exception.StripesRuntimeException: Something is trying to access the current Stripes configuration but the current request was never routed through the StripesFilter! As a result the appropriate Configuration object cannot be located. Please take a look at the exact URL in your browser's address bar and ensure that any requests to that URL will be filtered through the StripesFilter according to the filter mappings in your web.xml.


After spending quite some time trying to make it work, even going through the StripesFilter source code, the answer was surprisingly simple:

Edit web.xml and change the servlet filter's mapping from
    <filter-mapping>
        <filter-name>StripesFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>StripesFilter</filter-name>
        <servlet-name>StripesDispatcher</servlet-name>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
to
    <filter-mapping>
        <filter-name>StripesFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>StripesFilter</filter-name>
        <url-pattern>*.action</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

It appears as if WildFly does not like the <servlet-name>StripesDispatcher</servlet-name> and simply ignores it. When that is replaced by the pattern of the Stripes actions, it works fine: <url-pattern>*.action</url-pattern>

Maybe this saves someone else from hours of head-scratching.

1 comment:

  1. It worked fine for me (using StripesDispatcher) so perhaps you had some other configuration setting getting in the way.

    ReplyDelete