Creating "skinny" RichFaces WARs for JBoss AS 7

The module system introduced with JBoss AS 7 means the application server no longer (by default) expose its internal libraries for applications to use. While on the one-hand this is great news for those aiming to write truly portable applications, it is on the other-hand unfortunate that we have to include these dependencies in our wars.

 

Fortunately, JBoss AS 7 provides a means to selectively expose its internal libraries for aplication use. The result is that we can create "skinny" wars by exposing the correct JBoss AS 7 modules to our application. This article will specifically detail how you can reduce the number of Richfaces dependencies one must include by taking advantage of this modular sharing feature.

 

The following are the JBoss AS 7 modules that are of interest to those deploying RichFaces applications:

  • com.google.guava (as of JBoss AS 7.1)
  • org.w3c.css.sac, net.sourceforge.cssparser these modules were removed with AS 7.1.2

 

Exposing these modules is as simple as adding the following line to your Manifest.mf file:

 

Dependencies: com.google.guava

 

For maven users, this can be achieved by adding the following to your pom.xml:

 

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Dependencies>com.google.guava</Dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

 

 

 

And that does it! With the above Manfiest entry, we no longer need to bundle the respective jars in our application.