Maven ear design with ejb and military modules

im is working on a web application with maven and jboss 7 that will coordinate 3 ear and war ejb modules, so war will have ejb as a dependency and ejb will be ear module at the same time, so when i do this i get the same ejb twice this tree

ear ...Mywar ........Myejb ...Myejb 

Is this structure correct or should I change another

pom.xml for war:

  <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>tn.war.ep</groupId> <artifactId>businessModule</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> ..... <dependency> <groupId>tn.linckia.epgp</groupId> <artifactId>ejbModule</artifactId> <version>0.0.1-SNAPSHOT</version> <type>ejb</type> </dependency> </dependencies> </project> 

pom.xml for ear:

  <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>tn.war.ep</groupId> <artifactId>earModule</artifactId> <version>0.0.1</version> <packaging>ear</packaging> <build> <plugins> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.4</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.6</version> <configuration> <modules> <webModule> <groupId>tn.war.ep</groupId> <artifactId>businessModule</artifactId> <bundleFileName>businessModule.war</bundleFileName> <contextRoot>/businessModule</contextRoot> </webModule> <ejbModule> <groupId>tn.war.ep</groupId> <artifactId>ejbModule</artifactId> <bundleFileName>ejbModule.jar</bundleFileName> </ejbModule> </modules> <displayName>Security</displayName> </configuration> </plugin> </plugins> <finalName>AuthModule</finalName> </build> <dependencies> <dependency> <groupId>tn.war.ep</groupId> <artifactId>businessModule</artifactId> <version>0.0.1-SNAPSHOT</version> <type>war</type> </dependency> <dependency> <groupId>tn.war.ep</groupId> <artifactId>ejbModule</artifactId> <version>0.0.1-SNAPSHOT</version> <type>ejb</type> </dependency> </dependencies> </project> 
+2
java java-ee maven jboss
source share
3 answers

The correct way to configure the EAR module is to have the JARB JARB dependent on the β€œprovided” area in the WAR module and have the EJB jar directly below the EAR, as shown below:

 EAR | |-lib/someutil.jar |-EJB.jar |-my-web.war | |-WEB_INF/lib | |-coolutil.jar |-EJB2.jar 

But my-web.war may depend on any EJB.jar, but it is allowed at runtime by the container. So, note that the ejb dependency is as "provided" (by the container) in WAR pom.xml.

+3
source share

Option 1

Yon doesn't even need an ear. You can just put all your EJBs as banks in a war. Just add EJB projects depending on your military project.

Option: # 2

If you still want an EAR. All EJB project releases must be banks. And the output of the web project should be war. And finally, these EJB banks and the web will go into one EAR. This is an old-fashioned way, so that it is simple, you can follow the method described above in Option No. 1.

+1
source share

I had this problem and changing the ejb packaging tag from ejb to jar in ejb pom.xml modules fixed the problem. I do not know why!

0
source share

All Articles