JBoss AS 7.1 dependency conflicts due the xfire-1.2.6 dependencies wss4j-1.5.1 and xmlsec 1.3.0 - jboss

I'm trying to deploy legacy code on JBoss AS 7.1 but I'm struggling with conflicting dependencies due wss4j and xmlsec
I've created a jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding
some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
<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="javaee.api" />
<module name="org.apache.santuario.xmlsec" />
</exclusions>
<dependencies>
<module name="javaee.api">
<imports>
<exclude-set>
<path name="org/apache/xml/security/**" />
<path name="org/apache/ws/security/**" />
</exclude-set>
</imports>
</module>
</dependencies>
</deployment>
But this results in:
Caused by: java.lang.NoSuchMethodError: org.apache.xml.security.transforms.Transform.init()V
at org.apache.ws.security.WSSConfig.<init>(WSSConfig.java:81) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSConfig.getNewInstance(WSSConfig.java:95) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSConfig.<clinit>(WSSConfig.java:47) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSecurityEngine.<clinit>(WSSecurityEngine.java:51) [wss4j-1.5.1.jar:]
at org.apache.ws.security.handler.WSHandler.<clinit>(WSHandler.java:62) [wss4j-1.5.1.jar:]
at com.realdolmen.forens2.service.kbo.impl.KBOConsultServiceImpl.signRequest(KBOConsultServiceI
And when I change the path names to:
<exclude-set>
<path name="org/apache/xml/security" />
<path name="org/apache/ws/security" />
</exclude-set>
It results in:
Caused by: java.lang.NoSuchMethodError: org.apache.xml.security.keys.KeyInfo.init()V
at org.apache.xml.security.Init.init(Unknown Source) [xmlsec-1.3.0.jar:]
at org.apache.ws.security.WSSConfig.<init>(WSSConfig.java:72) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSConfig.getNewInstance(WSSConfig.java:95) [wss4j-1.5.1.jar:]
and what's really driving me crazy is that the correct versions appear in the stacktrace.

I've rewritten the legacy code with CXF..

Related

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

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

log4j2 2.10.0 will not deploy on jboss EAP 7

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?

Jboss configuration to load EAR jars for xerces and xalan

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.

classloading problems with Wildfly 8.0.0

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.

Cannot access Seam Components within JAR from WAR in [JBOSS 7.1.1.FINAL and SEAM 2.2.1.CR2]

Problem: I have an ejb-jar-1.jar which defines EJBs and Entities. The project structure is listed below. During deployment all EJBs are successfully bootstraped > started and their JNDI locations are printed in a log file. There's a class in my WAR file which needs to access a NAMED QUERY defined on an Entity which resides inside ejb-jar-1.jar. When this piece of code is run it throws an illegalArgumentException saying NAMED QUERY cannot be found. On a different note I also cannot get reference to SEAM components that were started when ejb-jar1.jar was deployed. I printed the JNDI tree from app-war.war file and it does not have any JNDI resources from ejb-jar-1.jar. So, I believe this is a context issue where JNDI resources available in ejb-jar-1.jar cannot be seen from app-war.war.
Any suggestions on how to access JNDI resources available in ejb-jar-1.jar from app-war.war?
Deployement Info
* JBOSS 7.1.1.FINAL
* Uses seam framework: jboss-seam-2.2.1.CR2.jar
* Uses Hibernate 3.4.0.GA
main-ear.ear
|__META-INF
| |____jboss-deployment-structure.xml
| |____application.xml
| |____jboss-app.xml
| |____MANIFEST.MF
|__lib
| |____somejar.jar
| |____somejar.jar
|__ejb-jar-1.jar
|__ejb-jar-2.jar
|__jboss-seam-2.2.1.CR2.jar
|__commons-lang-2.4.jar
|__commons-codec-1.1.jar
|__jasypt-1.6.jar
|__app-war.war
jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclusions>
<module name="javax.faces.api" slot="1.2"/>
<module name="com.sun.jsf-impl" slot="1.2"/>
<module name="org.hibernate" slot="main"/>
<module name="org.hibernate.validator" slot="main"/>
<module name="org.apache.commons.lang"/>
<module name="org.apache.commons.collections"/>
<module name="org.apache.commons.codec"/>
<module name="org.picketlink" slot="main"/>
<module name="org.picketbox" slot="main"/>
<module name="org.javassist" slot="main"/>
<module name="org.dom4j" slot="main"/>
</exclusions>
<dependencies>
<module name="javax.faces.api" slot="1.2" export="true"/>
<module name="com.sun.jsf-impl" slot="1.2" export="true"/>
<module name="org.javassist" slot="1" export="true"/>
<module name="org.apache.commons.logging" export="true"/>
</dependencies>
</deployment>
<sub-deployment name="app-war.war">
<exclusions>
<module name="javax.faces.api" slot="main"/>
<module name="com.sun.jsf-impl" slot="main"/>
</exclusions>
<dependencies>
<module name="javax.faces.api" slot="1.2"/>
<module name="com.sun.jsf-impl" slot="1.2"/>
<module name="deployment.main-ear.ear.ejb-jar-1.jar" />
<module name="deployment.main-ear.ear.ejb-jar-2.jar" />
<module name="deployment.main-ear.ear.jboss-seam-2.2.1.CR2.jar"/>
</dependencies>
</sub-deployment>
<module name="deployment.main-ear.ear.jasypt-1.6.jar" />
<module name="deployment.main-ear.ear.commons-codec-1.1.jar" />
<module name="deployment.main-ear.ear.commons-lang-2.4.jar" />
</jboss-deployment-structure>
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/application_6.xsd"
version="6">
<description>myapp</description>
<display-name>myapp</display-name>
<initialize-in-order>true</initialize-in-order>
<library-directory>lib</library-directory>
<module>
<ejb>ejb-jar-1.jar</ejb>
</module>
<module>
<ejb>ejb-jar-2.jar</ejb>
</module>
<module>
<ejb>jboss-seam-2.2.1.CR2.jar</ejb>
</module>
<module>
<web>
<web-uri>app-war.war</web-uri>
<context-root>/app</context-root>
</web>
</module>
</application>
Bit late but oh well...for EE6 you need to use JNDI portable syntax, eg. add following annotations to all beans in the secondary module
#JndiName("java:app/NameOfModule/NameOfBean")
Think you need seam.properties in your jar in META-INF