0

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>
John
  • 276
  • 1
  • 9
  • 29
  • This is a jboss question, not a Maven question. You should tag it that way. – J Fabian Meier May 19 '21 at 06:30
  • 2
    You need to include a jboss deployment descriptor indicating you want to prefer jars from your war over those from the server. I.e. parent-last classloading or whatever that is called nowadays. Trying to solve this with maven won't work. – M. Deinum May 19 '21 at 06:31
  • @M.Deinum but if I do that in jboss deployment descriptor, then it will done for every war that is deployed on jboss. I want to this this only for my specific war file. As on our jboss more than 20 apps are deployed. – John May 19 '21 at 07:19
  • 1
    No it won't as the descriptor is part of this war. – M. Deinum May 19 '21 at 07:34
  • @M.Deinum ok let me look into it – John May 19 '21 at 09:28
  • @M.Deinum but I have a springboot project that doesn't contain the web.xml file. And if I somehow add the web.xml then can you guide me as what kind of configuration do I need to add in that file to set the priority higher – John May 19 '21 at 12:35
  • I nowhere mentioned the web.xml... I mentioned the jboss specific deployment descriptor, which contains all sorts of stuff like classloading preference, which modules to use from where, which to exclude etc. etc. – M. Deinum May 19 '21 at 12:43
  • @M.Deinum I searched online for deployment descriptor it gave result as web.xml. Please can you share a link or something. It would be very helpfull. – John May 19 '21 at 12:51
  • You are using JBoss, read the jboss documentation which shows the `jboss-deployment-structure.xml`. Assuming that you are using a recent version of JBoss or WildFly. – M. Deinum May 19 '21 at 13:16
  • @M.Deinum I tried creating jboss-deployment-descriptor.xml and added it to web-inf folder, but still results in same error. Adding content of jboss descriptor in next cmt. – John May 19 '21 at 17:35
  • 1
    Please don’t add additional information as comments, as those are totally unreadable. Instead edit your question and add it with proper formatting. – M. Deinum May 19 '21 at 18:24
  • @M.Deinum Done that please check. – John May 20 '21 at 06:03

2 Answers2

1

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>
Hajed.Kh
  • 408
  • 3
  • 11
  • I have one question, Actually I have mentioned my jackson jar are added by another team in custom fb_library, and it is loading from their. And they have added fb_library in standalone.xml as global module. So Will this solution work in that case too??? – John May 21 '21 at 18:10
  • Yes, coz jboss-deployment-structure control class loading so it doesn't matter from where the module was inected it will be excluded in the class loading process. __document_: https://docs.jboss.org/author/display/AS7/Class%20Loading%20in%20AS7.html#:~:text=JBoss%20Deployment%20Structure%20File,%2DINF%20for%20web%20deployments). – Hajed.Kh May 22 '21 at 06:00
  • Not working in my case, even after excluding by package name. And Please see my jboss-deployment-structure.xml file – John May 24 '21 at 09:35
  • Still facing this error: Caused by: java.lang.ClassCastException: com.fasterxml.jackson.datatype.jdk8.Jdk8Module cannot be cast to com.fasterxml.jackson.databind.Module"} – John May 24 '21 at 09:36
  • can you please have a look as it is not working – John May 28 '21 at 04:07
  • obviously, it's a classCastException. does this issue appears when you did exclude your target modules? please share the server logs and the scenario done – Hajed.Kh May 28 '21 at 09:24
  • Yes this issue appeared after the exclusion also. In the question I have updated the jboss-deployment-structure.xml that I wrote and it did not worked. And basically ClassCastException: is there, currently I am unable to connect to server will share logs after a while. Can you guess or make an assumption as why my jboss-deployment-structure.xml is not working – John May 28 '21 at 11:24
  • Actually your jboss-deployment-structure.xml is working fine ( the exclusion process done successfully). There is something wrong with your application itself,I think one of the excluded modules is needed in your classpath. – Hajed.Kh May 28 '21 at 21:01
  • Does excluding it from jboss-deployment-structure.xml, also excludes it from loading altogether, As I have to load the latest version of jackson that I add in POM file, but what was happening is JBOSS container had already Jackson but its version was quite old, I just need to override that version. – John May 29 '21 at 05:44
  • 1
    Exclusion in the modules section is done with the module structure name so any module that matches the specified name will be excluded (for any version). – Hajed.Kh May 29 '21 at 17:29
0

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