Rewrite in EARs with skinny wars

Splash Forums Rewrite Users Rewrite in EARs with skinny wars

This topic contains 4 replies, has 2 voices, and was last updated by  Lincoln Baxter III 8 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #24223


    I have an EAR with two webapps, both of them using Rewrite. Everything works as expected.

    When I change packaging to use skinny wars (using Maven EAR plugin), Rewrite no longer starts up. There are no error messages, Rewrite is simply ignored. I use JBoss 7.1.1, by the way.

    I tried configuring Rewrite with Annotations, the SPI and the CDI extension.

    How can I force Rewrite to startup when it is located in an EAR’s lib directory?


    Hmmm… I’m guessing that in order for this to work, you will need to manually add Rewrite to your web.xml in each WAR file. The default servlet filter registration for Rewrite is done in a web-fragment.xml, which is probably not picked up by WARs when you are referencing libraries from the EAR deployment classpath.

    The Servlet 3.0 spec section 8.2.1 says: “Only jar files that are packaged in
    WEB-INF/lib are scanned for META-INF/web-fragment.xml”

    So you’ll need to add this to each web.xml:

          <filter-name>OCPsoft Rewrite Filter</filter-name>
          <filter-name>OCPsoft Rewrite Filter</filter-name>

    Once that is done, you should be up and running. If you encounter any other strange behavior, it may be due to some ServiceLoader issues but we can work through those if they are a problem. EAR’s are weird 🙂


    I have just updated the documentation to reflect this:

    Let me know how this goes for you and I’ll keep updating the docs. Thanks!



    Your solution works perfectly. Thanks for the quick reply and for updating the documentation.

    I’d like to use this place to document a minor problem that I stepped into using the auto-deploy feature of my IDE:
    Upon ear creation, the maven-ear-plugin removes the duplicate jars from the war files. Your IDE might not do this. In my environment (Eclipse, JBoss Tools, JBoss AS 7, Maven) a deployment was produced that contained Rewrite both in the ear’s lib and each war, resulting in errors: “Cannot forward after response has been committed”.

    The solution was to set the scope of Rewrite in the wars to provided.
    Now the EAR works both in the IDE and when manually built with Maven.


    Great! I’m glad you got this working, and I’ll update the documentation with your notes!

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.