1

I have an ear file which contains a .war file and a number of .jar files including Spring WS and Hibernate 3. This app is to be ported from another app server to Wildfly.

So far, this has been a royal pain due to all the modules that need to be created and their almost infinite dependencies.

I have created a jboss-deployment-structure.xml file in which I've declared the war dependencies:

<sub-deployment name="xxx.war"> 
    <dependencies>
       <module name="org.hibernate" slot="3"/>  
       <module name="org.spring.jdbc" />
       <module name="org.spring.beans" />
       <module name="org.spring.core" />
       <module name="org.slf4j" />
    </dependencies> 
</sub-deployment>

When attempting to deploy the app, I get the following error:

Caused by: java.lang.ClassNotFoundException: org.hibernate.event.PreUpdateEventListener from [Module "deployment.xxxEAR.ear.xxp_jar.jar:main" from Service Module Loader]

The problem is, how do I update deployment.xxxEAR.ear.xxp_jar.jar to include the proper module dependencies i.e. <module name="org.hibernate" slot="3"/>?

Rémi Bantos
  • 1,899
  • 14
  • 27
Andreas
  • 115
  • 2
  • 11

2 Answers2

0

If you use Wildfy 10, hibernate 3 support has been removed.

What version of Wildfly do you use exactly?

If you use the Wildfly 10 version, and still want to use hibernate 3 version, you could check that you have all hibernate 3 maven dependencies in your packaged webapp.

You could also exclude the hibernate jboss module like this in your jboss-deployment-structure.xml file, so your webapp will not rely on Wildfly hibernate jboss module anymore:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <exclusions>
            <module name="org.hibernate" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>
Rémi Bantos
  • 1,899
  • 14
  • 27
  • Remi, thanks for responding to my question. To respond to your suggestions, 1. I cannot ignore Hibernate 3. 2. I included this as a module under the system modules folder. All seems to be fine except when Wildfly attempts to deploy the sub-dployment deployment.xxxEAR.ear.xxp_jar.jar . This is where it begins to complain that Hibernate does not exist. – Andreas Feb 12 '16 at 19:10
  • Hi Andreas. Why can't you ignore Hibernate 3 jboss-module exactly by modifying your ear as you said that it already contains Hibernate 3 libs? Also, could you share your custom hibernate jboss-module? (file listing plus descriptor). Thks – Rémi Bantos Feb 12 '16 at 19:17
  • Hi Remi, how do I create the dependencies via the ear? Am I forced to use a pom.xml file? This app is one that I inherited. It's still using Ant to build in Eclipse. – Andreas Feb 12 '16 at 19:22
  • Ok, first thing is that for your ear dependencies you can either rely on a jboss-module (sometimes no need to do anything with the [implicit module dependencies](https://docs.jboss.org/author/display/WFLY8/Implicit+module+dependencies+for+deployments)), or include the needed libs in your package (ear, war, etc...). As your ear normally contains all hibernate 3 libs, you normally just have to add the hibernate exclusion in your ear jboss-deployment-structure.xml file. Then, no need to configure maven for that (even if dependencies mgt is easier with maven, or Ivy + ANT, ...) – Rémi Bantos Feb 12 '16 at 19:31
  • Sadly, I continue to get the following: for bean with name 'xxxListener' defined in class path resource [config/context-hibernate.xml]: problem with class file or dependent class; nested exception is java.lang.LinkageError: Failed to link com/bb/cc/xxy/xxp/listener/xxxListener (Module \"deployment.xxxEAR.ear.persistence_jar.jar:main\" from Service Module Loader) – Andreas Feb 12 '16 at 19:40
  • @Andreas, what version of Wildfly do you use exactly? Have you managed to fix your last issue? – Rémi Bantos Feb 15 '16 at 16:22
  • Hi Remi, We're using Wildfly 10. I just updated the application.xml file to include the Hibernate modules that are contained within the ear file and remove those, as per your suggestion, that are in the systems module within Wildfly. Unfortunately, I am still getting this exception: Caused by: java.lang.ClassNotFoundException: org.hibernate.event.PreUpdateEventListener – Andreas Feb 15 '16 at 18:48
0

If you are using Wildfly 9 or less than you can do following steps to bundle hibernate 3.5.6 along with your application. Add all jars into lib folder of ear. Add jboss-deployment-structure.xml into ear Meta-Inf directory.

persistent.xml => It's important to add HibernatePersistence provider and provider module as hibernate3-bundled.

<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd" version="1.0" >
   <persistence-unit name='pursem'>
   <provider>org.hibernate.ejb.HibernatePersistence</provider>
   <jta-data-source>java:/com/env/jdbc/OracleDS</jta-data-source>
   <properties>
      <property name="jboss.entity.manager.jndi.name" value="java:EntityManager/rsem"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
      <property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" />
      <!-- property name="hibernate.hbm2ddl.auto" value="update"/ -->
  </persistence-unit>

</persistence>

jboss-deployment-structure.xml => Remove wildfly assembled hibernate

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>  
    <exclusions>  
      <module name="org.hibernate"/>  
    </exclusions>  
  </deployment>
</jboss-deployment-structure>