Use packaged hibernate version in EAR

930 views Asked by At

I'm deploying my EAR on JBoss EAP 7.0.0, which has the following structure:

app.ear
|-- ejb.jar
|-- app.war
|-- lib
     |-- hibernate-core-5.2.10.Final.jar
     |-- hibernate-hibernate-spatial-5.2.10.Final.jar
     |-- hibernate-commons-annotations-5.0.1.Final.jar
|-- META-INF
     |-- application.xml
     |-- jboss-app.xml 

I added a small piece of code in one of my EJB bean that prints org.hibernate.Version.getVersionString() to know which version of Hibernate my application is using and it gives me 5.0.9.Final-readhat-1 instead of something like 5.2.10.Final.

I've read a lot about classloading issues (especially here and here), but after many different trials, I couldn't find a way to make JBoss use the packaged version of Hibernate in my EAR.

It looks like the tag is ignored in EAP 7 ? It seems that the classloading has changed in JBoss AS 7.

Here is the content of my jboss-app.xml:

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-app>   
  <loader-repository>  
    my.package:archive=app.ear  
    <loader-repository-config>   
    java2ParentDelegation=false  
    </loader-repository-config>  
  </loader-repository>   
</jboss-app> 

Is there a way to force JBoss EAP 7 to load the classes from my EAR prior to the bootstrap classloader ?

Note: I also posted this question here.

======================================================= EDIT

I tried with this jboss-deployment-structure.xml:

<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="org.hibernate" />
        </exclude-subsystems>
        <exclusions>
            <module name="org.hibernate" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

During the deployment, I get the following error:

{"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"app.ear/ejb.jar#app-ejbPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"app.ear/ejb.jar#app-ejbPU\": java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.envers.boot.internal.EnversIntegrator not a subtype
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.envers.boot.internal.EnversIntegrator not a subtype"}}}}
1

There are 1 answers

3
Usagi Miyamoto On

JBoss 7 (and WildFly) is using a modules system instead of class loaders to separate different apps and libraries.

Try to disable hibernate in your app: Place a jboss-deployment-stucture.xml file in your EAR's META-INF folder:

<jboss-deployment-structure>
  <deployment>
    <exclusions>
      <module name="org.hibernate" />
    </exclusions>
  </deployment>
</jboss-deployment-structure>

See: https://docs.jboss.org/author/display/WFLY10/Class+Loading+in+WildFly