Consider following structure of jboss-deployment-structure.xml inside META-INF of ear
<!-- Make sub deployments not isolated so they can see each others classes without a Class-Path entry (default is true) -->
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.xerces" />
</exclusions>
</deployment>
<sub-deployment name="mySubDeployment.war">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
<dependencies>
<system>
<paths>
<path name="com/sun/org/apache/xerces/internal/dom"/>
<path name="com/sun/org/apache/xerces/internal/xni"/>
<path name="com/sun/org/apache/xerces/internal/jaxp"/>
</paths>
</system>
</dependencies>
</sub-deployment>
Given that, I have excluded default org.apache.xerces module from deployment (line#11) and deployed custom xercesImpl.jar in APP-INF/lib folder or ear. Also I have added path dependencies for mySubDeployment.war sub-deployment.
From where classes of xerces will be loaded for mySubDeployment.war? From the default com.apache.xerces module of WildFly or custom jar deployed in APP-INF/lib?
What is the exact meaning of adding path dependencies in sub-deployment? Will that ignore the exclusions (i.e. org.apache.xerces here) under main deployment?
You shouldn't really need those paths. You'll also have to exclude xerces for each sub-deployment.
Also the APP-INF directory is not a standard Java EE directory. You'll need to put libraries in the /lib directory of your EAR.
Related
I have two .Ear files, namely ABC.EAR and XYZ.EAR.
ABC.ear has some dependencies on some jars which are in XYZ.ear.
I cannot pack them into one .EAR file.
I cannot put the used libraries in lib folder of WildFly(WildFly\modules\system\layers\base).
jars which are in XYZ.ear.
If the jars are sub-deployments, you can specify dependencies in jboss-deployment-structure.xml in dependent ear.
E.g. ABC.ear/META-INF/jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="deployment.XYZ.ear.xxxx1.jar"> <!-- xxxx1.jar is a sub-deployement of XYZ.ear -->
<imports>
<include path="**"/>
</imports>
</module>
<module name="deployment.XYZ.ear.xxxx2.jar"> <!-- xxxx2.jar is a sub-deployement of XYZ.ear -->
<imports>
<include path="**"/>
</imports>
</module>
<!-- other dependencies here ... -->
</dependencies>
</deployment>
</jboss-deployment-structure>
You can check the list of sub-deployments for the ear in the WF management console: Deployments menu -> select ear -> Subdeployments.
If the jars are just libs (NOT sub-deployments), then you should be able to add the same libs to ABC.ear.
I need to exclude default httpcomponent module from my application, but I also use restasy and don't want to exclude or broke it. For httpcomponent I want to use versions from dependencies in my project. Is it possible with JBoss EAP 7.1?
Version of modules in jboss :
jackson-databind-2.8.9.redhat-1
jackson-core-2.8.9.redhat-1
jackson-annotations-2.8.9.redhat-1
I've tried to add to jboss-deployment-structure.xml this config but it didn't help:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.httpcomponents" />
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.jboss.resteasy.resteasy-jettison-provider"/>
</exclusions>
<dependencies>
</dependencies>
</deployment>
</jboss-deployment-structure>
It should work, I can provide you a tested example (I've excluded the jettinson provider for my web app):
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jettison-provider"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
I see only modules in your question, do you have the correct deployment -> exclusions structure?
If you need a list of JBoss EAP 7 modules, go here.
There is a jar which loads native libraries .so files. This jar is available as a jboss module on the server. Native files can be loaded only once per classloader.
There are two war modules war1, war2 inside an ear1 file. if the module is configured as jboss module in both war1 & war2, I have no issues. But I am looking for an alternative where if i configure the jar which is loading the native library in the earfile/lib and the war refers from there, does that work. That particular class should load only once and shoudl be available in both the war files.
Solution:
We need to add sub-deployment section to the jboss deployment xml file inside ear/Meta-INF folder. That way the jboss module can be made available to all other submodules/war modules.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.aexp.sec.crypto" export="TRUE" />
</dependencies>
</deployment>
<sub-deployment name="crypto-war1-1.0-SNAPSHOT.war">
<dependencies>
<module name="com.aexp.sec.crypto" />
</dependencies>
</sub-deployment>
<sub-deployment name="crypto-war2-1.0-SNAPSHOT.war">
<dependencies>
<module name="com.aexp.sec.crypto" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Note: For the Benefits of the future users, adding the solution of #Vamshidhar Cheburthy below,
We need to add sub-deployment section to the JBoss deployment XML file inside ear/Meta-INF folder. That way the JBoss module can be made available to all other submodules/war modules.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.aexp.sec.crypto" export="TRUE" />
</dependencies>
</deployment>
<sub-deployment name="crypto-war1-1.0-SNAPSHOT.war">
<dependencies>
<module name="com.aexp.sec.crypto" />
</dependencies>
</sub-deployment>
<sub-deployment name="crypto-war2-1.0-SNAPSHOT.war">
<dependencies>
<module name="com.aexp.sec.crypto" />
</dependencies>
</sub-deployment>
I'm trying to convert my project from EAP 6.3 to Wildfly Swarm...
I'm having some trouble with CXF.
I've got the fraction dependency:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>camel-cxf</artifactId>
</dependency>
And then later, I include this, because otherwise I get a "package org.apache.cxf.message does not exist" error in my Camel Processor code
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.9</version>
</dependency>
So if I include it, I get the error:
Apache CXF library (cxf-core-3.1.9.jar) detected in ws endpoint
deployment; either provide a proper deployment replacing embedded
libraries with container module dependencies or disable the
webservices subsystem for the current deployment adding a proper
jboss-deployment-structure.xml descriptor to it. The former approach
is recommended, as the latter approach causes most of the webservices
Java EE and any JBossWS specific functionality to be disabled.
Ok, so maybe there's a lib conflict between the camel-cxf modules and my jar... or it's not picking up my jboss-deployment-structure.xml file?
I've tried a few things as suggested by other posts.
I tried adding this to jboss-deployment-structure.xml under ${basedir}/src/main/webapp/WEB-INF and adding the xml file to the webResources of the maven-war-plugin.
<deployment>
<exclude-subsystems>
<subsystem name="webservices" />
</exclude-subsystems>
</deployment>
I've also tried adding this to jboss-deployment-structure.xml:
<dependencies>
<module name="org.apache.cxf" />
<module name="org.apache.cxf.impl" />
</dependencies>
But I keep getting that error. So I'm not sure how to resolve this conflict. Any idea?
One Approach is to use Jboss provided CXF libraries and set <scope>provided</scope> for cxf-rt-transports-http, so that it compiles and but not package the CXF dependencies .
You find more on Jboss specific configuration
I recently updated apache httpclient to 4.5.1 and httpcore to 4.4.4, but for some reason my Jboss server has older versions of both (4.3.6). I'm pulling in the new versions via ivy, but they seem to be getting overwritten by the versions on the server. I've tried making my own jboss-deployment-structure.xml file, but it doesn't seem to be working and the documentation is scarce on exactly how this piece functions. At what level of specificity do I need to be blocking modules to prevent jboss loading dependencies that override ivy?
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.slf4j" />
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging" />
<module name="org.apache.httpcomponents" />
</exclusions>
<dependencies>
<module name="org.codehaus.jackson.jackson-core-asl" />
<module name="org.codehaus.jackson.jackson-mapper-asl" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Progress update: looks like the application relies on jaxrs and xalan, which in turn pull in the dependencies. ugh.
From the hibernate 3 jboss-eap-quickstarts:
<exclusions>
<!-- Exclude container version of hibernate. By default its version 4, we want
bundled version 3 loaded -->
<module name="org.hibernate" slot="main" />
</exclusions>
In your build for your application in the dependencies that pull in jaxrs and xalan set the scope of httpclient and httpcore to provided.