Use jboss pre-deployed module in maven ejb project
Goal
From my EJB maven project, I want to use commons-io and org.jgroups libraries, both of the jars have already been pre-deployed as modules in JBossAS 7.1.3 runtime.I use these jars as provided dependency to avoid packing redundant jars inside ejb project as lib jars.
JBoss AS 7.1.3 already has commons-io and org.jgroups deployed as module
...\jboss-as-7.1.3.Final\modules\org\apache\commons\io\main commons-io-2.1.jar ...\jboss-as-7.1.3.Final\modules\org\jgroups\main jgroups-3.0.14.Final.jar
Steps
in ejb project pom.xml, add// add commons-io and org.jgroups dependency with provided scope (so the jar won't be deployed alone with project archive as lib jars). This also makes the Eclipse IDE happy
...
<dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jgroups</groupId> <artifactId>jgroups</artifactId> <version>3.0.14.Final</version> <scope>provided</scope> </dependency>
// once packaged, the ejb jar won't have commons-io and org.jgroups in its lib directory. For server deployment, we then need to config project packaging plugin to add dependency to manifestEntries in ejb's MANIFEST.MF to use commons-io and org.jgroups as jboss pre-deployed module. Update ejb maven plugin to add dependency to manifestEntries as below
...
<plugin> <artifactId>maven-ejb-plugin</artifactId> <version>${version.ejb.plugin}</version> <configuration> <!-- Tell Maven we are using EJB 3.1 --> <ejbVersion>3.1</ejbVersion> <archive> <manifestEntries> <Dependencies>org.apache.commons.io, org.jgroups</Dependencies> </manifestEntries> </archive> </configuration> </plugin>
The generated MANIFEST.MF will have line as
Dependencies: org.apache.commons.io, org.jgroups
done. build project and deploy to JBoss.
No comments:
Post a Comment