JBoss AS and internal libraries

Submitted by Jochus on Mon, 11/01/2010 - 20:48 | Posted in: Java


Last week, I discovered something nice on the JBoss application server.
Imagine you have a webapplication (deployment : EAR) which has the following dependency:

<dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>3.0.1</version>
</dependency> 

JBoss AS has this library in $JBOSS_HOME/lib. Now, in my opinion it's really stupid to deploy the httpclient JAR in the EAR file, as JBoss is already providing you this library. It keeps the EAR file smaller, and the deployment process faster.

Now, you can put the library on provided:

<dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency> 

... but be aware that the implementation version of commons-httpclient is the same in JBoss as you specified in your pom.xml. There are 2 ways to check this:

  • browse to $JBOSS_HOME/lib and open commons-httpclient.jar. Go to: META-INF/MANIFEST.MF. You will see this:
    Manifest-Version: 1.0
    Specification-Title: JBoss
    Created-By: ari-49095-20050826-1856-linux-ia32 (BEA Systems, Inc.)
    Ant-Version: Apache Ant 1.6.5
    Implementation-Title: JBoss [Trinity]
    Specification-Version: 1.0
    Specification-Vendor: Apache Software Foundation
    Implementation-Vendor-Id: http://www.jboss.org/
    Extension-Name: httpclient
    Implementation-Version: 3.0.1
    Implementation-Vendor: Apache Software Foundation
    Implementation-URL: http://www.jboss.org/
    ... which means, the implemenation version is 3.0.1.
  • ... but last week, I discovered the $JBOSS_HOME/jar-versions.xml file which contains ALL the implementation versions. But it's confusing to look at this file:
    ...
    <?xml version="1.0" encoding="UTF-8"?>
    <jar-versions>
      <jar name="FastInfoset.jar" specVersion="1.0" specVendor="JBoss (<a href="http://www.jboss.org/">http://www.jboss.org/</a>)" specTitle="ITU-T Rec. X.891 | ISO/IEC 24824-1 (Fast Infoset)" implVersion="1.2.2" implVendor="Sun Microsystems, Inc." implTitle="Fast Infoset Implementation " implVendorID="com.sun" implURL="<a href="http://www.jboss.org/&quot">http://www.jboss.org/&quot</a>; sealed="false" md5Digest="c16cec395b7e7ed1f18e8ec58a5992d7"/>
      <jar name="activation.jar" specVersion="1.1" specVendor="Sun Microsystems, Inc." specTitle="JavaBeans(TM) Activation Framework Specification" implVersion="1.1" implVendor="Sun Microsystems, Inc." implTitle="Sun Java System Application Server" implVendorID="com.sun" implURL="<a href="http://www.jboss.org/&quot">http://www.jboss.org/&quot</a>; sealed="false" md5Digest="f7209f1d5a729bd3ec5b9a8f64aaf52d"/>
    ...

    So I wrote a small XSL file for mark up.

    1. create the file jar-versions.xsl next to jar-versions.xml with the following content:
       <?xml version="1.0"?>
       <!-- @author Jochen Hebbrecht (RealDolmen) -->
      <xsl:stylesheet xmlns:xsl="<a href="http://www.w3.org/TR/WD-xsl">&#10">http://www.w3.org/TR/WD-xsl">&#10</a>;	<xsl:template match="/">
      			<h1>JBoss internal libraries</h1>
      			<table width="100%" border="1">
      				<xsl:for-each select="//jar">
      					<tr>
      						<td><xsl:value-of select="@name"/></td>
      						<td><xsl:value-of select="@implVersion"/></td>
      					</tr>
      				</xsl:for-each>
      			</table>
      	</xsl:template>
      </xsl:stylesheet>
    2. add this line to jar-versions.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <?xml-stylesheet type="text/xsl" href="jar-versions.xsl"?>
      ...
    3. just open the XML file and enjoy the layout ;-)!

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.