I have jars within my ear lib which need to be preferred over the application server similar jars like xalan, xerces etc. Weblogic allows this to done as below and the application works fine now in weblogic - with the configuration below
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.oracle.com/technology/weblogic/920/weblogic-application.xsd">
<xml>
<parser-factory>
<saxparser-factory> org.apache.xerces.jaxp.SAXParserFactoryImpl </saxparser-factory>
<document-builder-factory> org.apache.xerces.jaxp.DocumentBuilderFactoryImpl </document-builder-factory>
<transformer-factory> org.apache.xalan.processor.TransformerFactoryImpl </transformer-factory>
</parser-factory>
</xml>
<prefer-application-packages>
<package-name>org.opensaml.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.xalan.*</package-name>
</prefer-application-packages>
</weblogic-application>
I need to do the same with jboss so that it excluded the similar jars which are present within its own library. I have tried the below
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="deployment.javaee.api" />
</dependencies>
<exclusions>
<module name="javaee.api" />
</exclusions>
</deployment>
<module name="deployment.javaee.api">
<dependencies>
<module name="javaee.api" export="true">
<imports>
<exclude path="org/opensaml/**" />
<exclude path="org/apache/xerces/**" />
<exclude path="org/apache/xalan/**" />
</imports>
</module>
</dependencies>
</module>
</jboss-deployment-structure>
Still it seems to pick up the jboss jars for xerces , xalan and opensaml. In case you have done such things before in JBOSS, your suggestion will be really appreciated.
Related
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>
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 :
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>
This answer solve my problems for com.fasterxml.jackson.dataformat.cbor
FYI
https://stackoverflow.com/a/37859612/14337508
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.
Needed to update our log4j2 from 2.7 to 2.10.0 to get JMS retries working.
When I try to deploy the ear with the 2.10.0 files, jboss is complaining with the following error:
Caused by: java.util.ServiceConfigurationError:
org.apache.logging.log4j.util.PropertySource: Provider
org.apache.logging.log4j.util.EnvironmentPropertySource not a subtype"},
We are also excluding the default jboss logger from our app
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging"/>
<module name="org.apache.commons.logging" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
These are the jars in my ear's lib folder for logging:
lib/log4j-api.jar
lib/log4j-core.jar
lib/log4j-slf4j-impl.jar
lib/log4j-web.jar
lib/slf4j-api.jar
lib/slf4j-ext.jar
Any suggestions? Maybe there is another new file I have to exclude?
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 am trying to deploy a Spring-JPA-Hibernate web application on Wildfly. First, I had problems with Hibernate which seemed to go away with
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate" slot="main" />
</exclusions>
<dependencies>
<module name="org.hibernate" />
</dependencies>
</deployment>
</jboss-deployment-structure>
then however, my org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean tried to parse its mappingResources (xml file), and I got the exception
Error while parsing (.... etc)
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1163)
... 44 more
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
which seems to suggest there is another dom4j on the classpath.
At this point I got lost, since tinkering again with jboss-deployment-structure.xml only made the server freeze with no error message soon after startup.
Is there a simple way just to tell Wildfly not to put on the classpath at least its dom4j (or better, not to add anything at all automatically)?
I think that you must choose a strategy to use the classes from Wildfly or to use the classes you provide in your application.
I have the similar issue with Liferay 6.2 GA3 deployed in Wildfly 8.2. I solved it using a deployment descriptor similar to:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.hibernate"/>
<module name="org.hibernate.validator"/>
<module name="org.jboss.as.jpa"/>
<module name="org.javassist"/>
<module name="javaee.api"/>
</exclusions>
<dependencies>
<!-- add the module and remove the dom4j in your application
or exclude the module and add the jar in your application -->
<module name="org.dom4j"/>
<module name="javax.mail.api"/>
<module name="org.apache.xerces"/>
<module name="org.jboss.modules"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
https://www.liferay.com/community/forums/-/message_boards/view_message/40321431#_19_message_47754919
If you want to use the Wildfly classes and deploy the JPA entities in Wildfly container, use a similar persitence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="MyApp" transaction-type="JTA" >
<!-- Data Source -->
<jta-data-source>java:jboss/datasources/MyApplicationPool</jta-data-source>
<!-- Class -->
<class>entities here </class>
<!-- Properties -->
<properties>
<!-- the persitence unit will be deployed in Wildfly and linked to spring
using JNDI https://docs.jboss.org/author/display/WFLY8/JPA+Reference+Guide#JPAReferenceGuide-BindingEntityManagerFactory%2FEntityManagertoJNDI -->
<property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/WildflyEntityManagerFactory" />
<property name="jboss.entity.manager.jndi.name" value="java:/WildflyEntityManagerVMS" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<!-- for the JODA datetime -->
<property name="jadira.usertype.autoRegisterUserTypes" value="true" />
</properties>
</persistence-unit>
Make reference to the Wildfly persitence unit in your Spring application:
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<jee:jndi-lookup id="entityManagerFactory"
jndi-name="java:jboss/WildflyEntityManagerFactory" expected-type="javax.persistence.EntityManagerFactory" />
And you should not need any specific jboss-deployment-structure.