Maven EJB packaging with dependent libraries

I am facing the question of how to properly package my enterprise (EAR) application using a simple WAR and EJB3 module for the JBoss7 application server. The thing is, the EJB module uses the XML-RPC library (from Apache), and I still get NoDefClassFound (classes from this xmlrpc library) during EAR deployment.

The fact is that maven- ejb- plugin does not pack dependencies inside the final EJB file, and maven- ear- plugin packs it in the root of the EAR directory.

When the EAR is deployed, INSTALL is called in the internal EJB module, but it does not find the xmlrpc lib class (it is not packaged with the EJB jar, but the EAR does not have an entry in the manifest).

EJB pom.xml

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cz.ctu.fee.voxport.app_logic</groupId> <artifactId>core</artifactId> <version>1.0</version> <packaging>ejb</packaging> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.xmlrpc</groupId> <artifactId>xmlrpc-common</artifactId> <version>3.1.3</version> </dependency> <dependency> <groupId>org.apache.xmlrpc</groupId> <artifactId>xmlrpc-client</artifactId> <version>3.1.3</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>2.3</version> <configuration> <ejbVersion>3.1</ejbVersion> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project> 

Is there any way how to cleanly solve this problem using Maven?

+7
source share
2 answers

I managed to solve the problem. It seems that these libraries should be packaged in the / lib directory, and not in the root of the EAR. Adding the defaultLibBundleDir element solved the problem.

eg:.

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.6</version> <configuration> <defaultLibBundleDir>lib</defaultLibBundleDir> ... 
+9
source

Have you left <addClasspath>true</addClasspath> in the EJB configuration?

Well, you can leave it like this, but you get a bunch of log entries (WARN), on the server start complaining about entries in the class. I prefer to set the value to false. <addClasspath>false</addClasspath>

+5
source

All Articles