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”
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 🙂
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.