Jboss EAP 7 - How to exclude implicit modules from deployment (javax.jms)?

I did not think that I would get here, but after many searches of Google and StackOverflow I am here.

This is my exact problem , except that I cannot afford to modify the code.

The WAR I'm trying to deploy includes a JMS library (i.e. javax.jms, which I cannot exclude from WAR), which is already loaded by default with Jboss EAP 7. The path to the jar looks something like this: jboss/modules/system/layers/base/javax/jms/api/ain/jboss-jms-api_2.0_spec-1.0.0.Final-redhat-1.jar . Due to these two different loading versions of the same classes, I get a ClassCastException.

 org.apache.activemq-ra.ActiveMQConnectionFactory cannot to be cast to javax.jms.ConnectionFactory 

So, I want Jboss to NOT load javax.jms so that my application can use the JAR included in the WAR.

So, I was wondering if there is a way to exclude the module globally (for all WAR deployments).

Other than that, deployment will work too. And I understand that this can be useful with jboss-deployment-structure.xml, but I can't get it to work.

Here is what I tried:

 <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <exclude-subsystems> <subsystem name="javax" /> <subsystem name="javax.jms" /> </exclude-subsystems> </deployment> </jboss-deployment-structure> 

and

 <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <exclusions> <module name="javax" /> <module name="javax.jms" /> <module name="javax.jms.api" /> </exclusions> </deployment> </jboss-deployment-structure> 

I put the file in the WEB-INF directory. This did not work. It still loaded the JMS class from the Jboss EAP modules folder. So how did I do it right?

+8
java jboss jboss-eap-7
source share
3 answers

You must remove the JMS API JAR from your deployment. You can still keep the JAR implementation of the JAR in your deployment, but this should probably end in the RAR, preferably outside of your deployment.

+2
source share

This link contains some things you could try.

In particular:

I think the problem is that activemq-all-5.4.2.jar contains javax.jms. *. Your deployment already gets this implicitly from the javaee.api module (see Additional information on implicity module dependencies here ). I do not think the / jar application is suitable for the Java EE package. You can simply remove the javax directory from activeemq-all-5.4.2.jar or use a different set of ActiveMQ banners in your module to limit it to just what you need.

and / or modifying your module.xml for ActiveMQ

 <module xmlns="urn:jboss:module:1.0" name="activemq"> <resources> <resource-root path="activemq-all-5.4.2.jar"/> </resources> <dependencies> <module name="javax.api"/> </dependencies> </module> 

There seems to be a method to embed ActiveMQ in Jboss if you're interested. I will not extract information from this article because it does not answer the original question.

+1
source share

The correct jboss-deployment-structure.xml is here:

 <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <exclude-subsystems> <subsystem name="messaging-activemq"></subsystem> </exclude-subsystems> <exclusions> <module name="javax.jms.api"></module> </exclusions> </deployment> </jboss-deployment-structure> 

This way you eliminate the messaging subsystem and the JMS api.

+1
source share

All Articles