inor
inor

Reputation: 2846

How to exclude the default Hibernate (5) from Wildfly 10 application?

(I've revised my question based on the helpful hint from James Perkins) I'm trying to upgrade from Jboss 4.2.3 to WildFly 10 is an involved process. In order not to change too many things I'd like to try get the application to work without changing the Hibernate dependency (to the default Hibernate 5).
The documentation explains how to use jboss 4.0 - 4.3 in various ways, none is clear, but every approach tells you to first "exclude the Hibernate 5 classes from your application".

I'd like to know how to that before i proceed. Currently after dropping the application in the standalone deployment folder and starting the server, I'm getting the following (cleaned-up/trimmed) messages in the log:

WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service MyEar.ear#my_unit'
HHH000412: Hibernate Core {5.0.10.Final}
HHH000206: hibernate.properties not found
HHH000021: Bytecode provider name : javassist
HCANN000001: Hibernate Commons Annotations {5.0.1.Final}

and

HV000001: Hibernate Validator 5.2.4.Final

It seems Hibernate 5 is used despite my exclusion above.
I should not be getting these messages. What is missing/wrong?

The following is a description of my application: The structure is the following:

.ear
    lib
    META-INF
    web.war
        META-INF
        WEB-INF
           lib
              jar1.jar
                 META-INF
              jar1.jar
                 META-INF
    ejb1.jar
        META-INF
    ejb2.jar
        META-INF

I've created a jboss-deployment-structure.xml file and placed it in all the META-INF folders in the tree (total of 6 places!). The .ear looks as advised to others with similar goal:

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

Upvotes: 2

Views: 8220

Answers (2)

Smutje
Smutje

Reputation: 18143

We had the problem of needing to upgrade Hibernate from 5.X (Wildfly provided) to 5.2.2.Final. There were two steps necessary:

  1. The .ear application/META-INF/jboss-deployment-structure.xml looks like

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <deployment> <exclusions> <module name="org.hibernate" slot="main" /> </exclusions> <dependencies> <module name="org.hibernate" slot="5.2.2.Final" /> </dependencies> </deployment> </jboss-deployment-structure>

  1. The persistence.xml has got an entry

<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.2.2.Final"/>

Upvotes: 0

James R. Perkins
James R. Perkins

Reputation: 17780

For an EAR you need to exclude the module for each subdeployment. See the class loading documentation for more details on that.

You can also use Hibernate 4.x with WildFly 10. Have a look at the JPA Reference documentation.

Upvotes: 1

Related Questions