How to exclude the specific jar from global module in jboss?

3.7k Views Asked by At

I have a war file that contains, some jackson dependencies and then when I try to deploy it on jboss eap 7.3 server, war deployment fails

Due to, as different version of these jackson jar are included via global modules. That I cannot or remove from their.

So I create a jboss-deployment-structure.xml file and tried excluding specific jar's inside the global module's but it did not worked.

But I was successful in excluding the whole global modules that I don't want.

This is what I tried!!

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <deployment>
    <exclusions>
      <module name="fb_library" />
    </exclusions>
  </deployment>
</jboss-deployment-structure>

This above config works, but it excludes the whole global fb_library folder, But as I needed to exclude some specific jar so tried this and it gave error as wrong format for jboss-deployment-structure.xml

This gave error of wrong config as mentioned above

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <deployment>
    <exclusions>
      <resources>  
        <resource-root path="jackson-core-2.6.6.jar"/>
        <resource-root path="jackson-annotations-2.6.0.jar"/>
        <resource-root path="jackson-databind-2.6.6.jar"/>
        <resource-root path="jackson-dataformat-cbor-2.6.6.jar"/>  
      </resources> 
    </exclusions>
  </deployment>
</jboss-deployment-structure>

PS:- I have updated the question, as suggested by some members in chat, previously I was asking the wrong question. Apologies for that.

Again I tried this and not working

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <deployment>
<exclusions>
<module name="com.fasterxml.jackson.core" />
<module name="com.fasterxml.jackson.annotation" />
<module name="com.fasterxml.jackson.databind.module" />
<module name="com.fasterxml.jackson.jaxrs" />
<module name="com.fasterxml.jackson.jaxrs.json" />
<module name="com.fasterxml.jackson.module.jaxb" />
    </exclusions>
  </deployment>
</jboss-deployment-structure>
2

There are 2 best solutions below

10
On

In jboss-deployment-structure, you are not allowed to add resources content (Jar files). you need to specify the module name added by the dependency jar file itself here is an example : here is a jackson jar that I want to exclude from jboss modules : JAckson module

the module name is : com.fasterxml.jackson.core and in the jboss-deployment-structure.xml it will be :

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <deployment>
    <exclusions>
      <module name="com.fasterxml.jackson.core" />
    </exclusions>
  </deployment>
</jboss-deployment-structure>
0
On

This answer solve my problems for com.fasterxml.jackson.dataformat.cbor FYI https://stackoverflow.com/a/37859612/14337508