3
votes

The JPA/Hibernate provider is bundled within my application, but I'm having trouble when deploying it to wildfly 8.1. Namely I'm using an OSS project called OpenXava, which is bundled with its own Hibernate version. I've previously had success with this on JBoss 5.1, but WildFly 8.1 gives me an error when I deploy it.

I've asked the lead developer of OpenXava, and he says it's most likely a problem with configuring WildFly to use a the JPA provider bundled in the war file. I've looked through the documentation for WF, and found the jboss.as.jpa.providerModule setting. I've tried setting this to application, and to hibernate3-bundled, and neither works. I've also tried excluding modules via jboss-deployment-structure.xml. This created some different errors, but didn't seem to be successful.

Does anyone have any clue what's going on?

My jboss-deployment-structure.xml looks like:

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

My persistence.xml looks like:

<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">
            
    <!-- Tomcat + Hypersonic -->
    <persistence-unit name="default">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>org.openxava.session.GalleryImage</class>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
        <property name="jboss.as.jpa.providerModule" value="application" />
        </properties>
    </persistence-unit>   

    <!-- JUnit Hypersonic -->
    <persistence-unit name="junit">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
            <property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost:1666"/>
        </properties>

When I deploy the application, it returns the following error (I'm using the example application MySchool.war provided in OpenXava):

13:15:17,563 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."MySchool.war".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."MySchool.war".FIRST_MODULE_USE: JBAS018733: Failed to process phase FIRST_MODULE_USE of deployment "MySchool.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_05]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_05]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_05]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011426: Could not deploy application packaged persistence provider 'org.hibernate.ejb.HibernatePersistence'
    at org.jboss.as.jpa.processor.PersistenceProviderHandler.deploy(PersistenceProviderHandler.java:81)
    at org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor.deploy(PersistenceBeginInstallProcessor.java:49)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    ... 5 more
Caused by: java.lang.ClassCastException: class org.hibernate.ejb.HibernatePersistence
    at java.lang.Class.asSubclass(Class.java:3293) [rt.jar:1.8.0_05]
    at org.jboss.as.jpa.processor.PersistenceProviderHandler.deploy(PersistenceProviderHandler.java:74)
    ... 7 more
 
13:15:17,587 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "MySchool.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"MySchool.war\".FIRST_MODULE_USE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MySchool.war\".FIRST_MODULE_USE: JBAS018733: Failed to process phase FIRST_MODULE_USE of deployment \"MySchool.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011426: Could not deploy application packaged persistence provider 'org.hibernate.ejb.HibernatePersistence'
    Caused by: java.lang.ClassCastException: class org.hibernate.ejb.HibernatePersistence"}}
2
I doubt if it's a problem that you can solve with jboss configuration. You configure the container only if you're using container managed persistence. Otherwise your war should be self contained. It's probably just a normal dependency management issue.Software Engineer
@EngineerDollery that's possible, but I don't really know where to start since I've already configured out JPA and Hibernate. What makes you believe Wildfly isn't trying to manage the persistence itself?Steve Sether
Wildfly won't manage your persistence unless you're writing EJBs with container managed persistence enabled.Software Engineer
@EngineerDollery Ok, so where do I proceed? I'm still lost, and cordoning off one avenue of possibility doesn't really help if I don't have another direction.Steve Sether
Well, it saves you time casting about in areas that are unlikely to help and helps focus your search for help in places that are more likely to be productive.Software Engineer

2 Answers

1
votes

According to Winldfly 8 documentation, you need to change the persistence provider from:

<provider>org.hibernate.ejb.HibernatePersistence</provider>

to:

<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
1
votes

I believe the reason of the issue is you missed this dependecy

<dependency>
 <groupId>org.jipijapa</groupId>
 <artifactId>jipijapa-hibernate4-3</artifactId>
 <version>1.0.1.Final</version>
</dependency>

After adding dependency I managed to use Hibernate 4.3.5.Final in Wildfly8.2.Final.