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"}}