JBoss AS 7: EJB dependency in another EAR

I have an EAR with the following structure:

ear.ear mywar.war lib jar1.jar jar2.jar jar3.jar 

I have several WARs in the deployment directory and I would like them to have jar1.jar. jar2.jar and jar3.jar from ear.ear as dependencies.

Is it possible?

I tried the following for jboss-deployment-structure.xml with no luck.

 <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <dependencies> <module name="deployment.ear.ear.jar1.jar"/> <module name="deployment.ear.ear.jar2.jar"/> <module name="deployment.ear.ear.jar3.jar"/> </dependencies> </deployment> </jboss-deployment-structure> <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <dependencies> <module name="deployment.ear.ear.lib.jar1.jar"/> <module name="deployment.ear.ear.lib.jar2.jar"/> <module name="deployment.ear.ear.lib.jar3.jar"/> </dependencies> </deployment> </jboss-deployment-structure> 

Is it possible to have non-ejb JAR dependencies in a separate EAR?

+4
source share
2 answers

You should be able to place the dependencies in the /lib folder of your ear, and your wars should see them.

From the JBoss AS7 documentation:

Ear deployments are multi-module deployments. This means that not all classes within the ear will necessarily have access to all other classes in the ear unless explicit dependencies are defined. From the default, the EAR / lib directory is a single module, and each WAR or EJB jar deployment is also a separate module. Units (wars and ejb-jars) always depend on the parent module, which gives them access to classes in EAR / lib, however they do not always have automatic dependency on each other

You can also learn more about loading classes in JBoss AS 7: https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

+2
source

Jar files in the ear are deployed as a single module. You can specify a dependency on them using jboss-deployment-structure.xml , specifying a dependency on the ear itself. You will also need to enable any ejbs separately and enable export="TRUE" .

For instance:

 <?xml version="1.0" encoding="UTF-8"? xmlns="urn:jboss:deployment-structure:1.2"> <jboss-deployment-structure> <deployment> <dependencies> <!-- our module depends on the libs within myear.ear --> <module name="deployment.myear.ear" export="TRUE"/> <!-- and these ejbs --> <module name="deployment.myear.ear.ejb1.jar" export="TRUE"/> <module name="deployment.myear.ear.ejb2.jar" export="TRUE"/> <module name="deployment.myear.ear.ejb3.jar" export="TRUE"/> </dependencies> </deployment> </jboss-deployment-structure> 
+2
source

Source: https://habr.com/ru/post/1497188/


All Articles