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.
Related
Wildfly Version: 21.0.2.Final
JDK Version: openjdk-11.0.2
Eclipselink: Migrating from 2.7.8 to 3.0.0 ( 2.7.8 working fine)
When I try to deploy EJB 3.2 (JPA 2.2) project I am getting the below issue
10:29:59,261 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."AAA-EAR.ear".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."AAA-EAR.ear".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment "AAA-EAR.ear"
at org.jboss.as.server#13.0.3.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:189)
at org.jboss.msc#1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc#1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
at org.jboss.msc#1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.persistence.PersistenceException: WFLYJPA0057: PersistenceProvider 'org.eclipse.persistence.jpa.PersistenceProvider' not found
at org.jboss.as.jpa#21.0.2.Final//org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.lookupProvider(PersistenceUnitServiceHandler.java:1001)
at org.jboss.as.jpa#21.0.2.Final//org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.nextPhaseDependsOnPersistenceUnit(PersistenceUnitServiceHandler.java:1044)
at org.jboss.as.jpa#21.0.2.Final//org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deploy(PersistenceUnitServiceHandler.java:137)
at org.jboss.as.jpa#21.0.2.Final//org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor.deploy(PersistenceBeginInstallProcessor.java:52)
at org.jboss.as.server#13.0.3.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:182)
... 8 more
Eclipselink 2.7.8 working fine, so I just updated eclipselink version to 3.0 in below module.xml.
Also I think no need to exclude javax as this folder does not in eclipselink 3.0 jar.
wildfly-21.0.2.Final/modules/system/layers/base/org/eclipse/persistence/main/module.xml
<module name="org.eclipse.persistence" xmlns="urn:jboss:module:1.5">
<properties>
<property name="jboss.api" value="public"/>
</properties>
<resources>
<resource-root path="jipijapa-eclipselink-21.0.2.Final.jar"/>
<resource-root path="eclipselink-3.0.0.jar">
<filter>
<exclude path="javax/**" />
</filter>
</resource-root>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.enterprise.api"/>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<module name="javax.xml.bind.api"/>
<module name="org.antlr"/>
<module name="org.dom4j"/>
<module name="org.jboss.as.jpa.spi"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.vfs"/>
</dependencies>
</module>
Below is my META-INF/persistence.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="AAA-EJB" transaction-type="JTA">
<provider>**org.eclipse.persistence.jpa.PersistenceProvider**</provider>
<jta-data-source>java:/Test</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.jpa.uppercase-column-names" value="true"/>
<property name="eclipselink.query-results-cache" value="false"/>
<property name="eclipselink.refresh" value="true"/>
<property name="eclipselink.cache.shared.default" value="false"/>
<property name="eclipselink.deploy-on-startup" value="true" />
</properties>
</persistence-unit>
</persistence>
Eclipselink 2.7.8 working fine but getting issue for Eclipselink 3.0.
Please help. Thanks.
I have migrated my application from jboss5.1.2-eap to jboss-7.2-eapand java6 to java8 but after migration it is starting giving me exception while starting the server.
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/dbcp/BasicDataSource
we have a datasource.xml file present in the classpath of the server, having the following line of code.
<bean id="beanName" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
<property name="maxActive" value="10"/>
Also we have commons-dbcp-1.2.2.jar present in the classpath but it is not working for jboss-7.2-eap.
Now I am not sure if commons-dbcp-1.2.2.jar is supported by jboss7-eap. as it is present in the classpath of the application(present in the loaded module), but still spring is not able to create the bean for datasource.
I suppose that datasource in Jboss EAP should be placed in standalone.xml configuration file and looks like here:
<datasource jndi-name="java:jboss/datasources/Altis" pool-name="Altis" enabled="true">
<connection-url>jdbc:oracle:thin:#255.255.255.255:1521:sid</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<security>
<user-name>username</user-name>
<password>passwd</password>
</security>
</datasource>
Given module information in the jboss-deployment-structure.xml inside the WEB-INF directory of the war file.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.oracle.sql" export="true"/>
<module name="org.apache.commons.dbcp" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Also the module directories should also follow the same naming convention as per the availability of your .class files inside the jar, like in my case I have created module org.apache.commons.dbcp as while opening commons-dbcp-1.2.2.jar file, .class files are present inside org/apache/commons/dbcp folder.
Note: In case of multiple modules, you need to identify there dependency if a module is dependent on other and that information will be given inside module.xml file. like
<module xmlns="urn:jboss:module:1.1" name="org.apache.commons.dbcp">
<resources>
<resource-root path="commons-dbcp-1.2.2.jar"/>
</resources>
<dependencies>
<module name="org.apache.commons.pool"/>
<module name="com.oracle.jdbc.driver"/>
</dependencies>
</module>
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?
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.
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..