3

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"}}
Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
Steve Sether
  • 140
  • 2
  • 9
  • 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 Jan 12 '15 at 22:22
  • @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 Jan 12 '15 at 22:32
  • Wildfly won't manage your persistence unless you're writing EJBs with container managed persistence enabled. – Software Engineer Jan 13 '15 at 16:45
  • @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 Jan 13 '15 at 18:46
  • 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 Jan 13 '15 at 19:15
  • You could start by removing all references to hibernate providers, jpa, etc, from your jboss config and get them back into your app configuration. Then, show us your pom and we'll go from there? – Software Engineer Jan 13 '15 at 19:17
  • @EngineerDollery As I've mentioned several times, I've already done that in the jboss-deployment-structure.xml. I'd list them again, but they're right above in the original post. I also mentioned the app is already configured with JPA and Hibernate in the app. This is simply the showcase app that the framework provider distributes that works in JBoss 5.1, and according to him, works in Weblogic. – Steve Sether Jan 13 '15 at 22:39
  • @EngineerDollery I realize you're trying to help me help myself, but you haven't provided me with anything I don't already know. I'm also a bit leery of your advice that the container doesn't manage persistence, since there's references in Wildfly to disable the container managed persistence. Thanks for your input. If you don't know what's wrong, that's fine, but so far this hasn't been all that useful of a conversation. – Steve Sether Jan 13 '15 at 22:58
  • Try updating to WildFly 8.2, may there is a bug in 8.1. – V G Jan 14 '15 at 09:31

2 Answers2

1

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>
Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • The persistence is being managed by the application, not the container, so I don't really understand how changing the persistence provider would help. For fun, I tried this and it didn't fix the underlying problem. – Steve Sether Jan 19 '15 at 21:50
  • Ok. One more thing. Why are you using: persistence_1_0.xsd? Shouldn't you use the 2.1 xsd too? – Vlad Mihalcea Jan 19 '15 at 21:53
  • I didn't write the persistence configuration details, it was done by Javier Paniza, the maintainer of the framework I'm using, OpenXava. – Steve Sether Jan 19 '15 at 21:56
  • Hibernate 4 changed some packages and your persistence.xml looks like it was meant for Hibernate 3. That's why I suggested that change. Try enabling Hibernate 3 with Wildfly. – Vlad Mihalcea Jan 19 '15 at 22:00
  • I'd actually like to disable WIldfly doing anything with the persistence at all. Hibernate and JPA are all managed internally via wildfly, with Hibernate 3 being provided in my war. The OpenXava maintainer said: Ask about how to use a different Hibernate/JPA version that the one included in Wildfly. The jars for Hibernate and JPA are included in WEB-INF/lib of your apps, so I don't know why it complaints. – Steve Sether Jan 19 '15 at 22:28
1

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.

Joey Wang
  • 21
  • 1
  • I'll try that tomorrow. Sometimes I'm astonished how hard configuring application containers is. Thanks. – Steve Sether Mar 27 '15 at 04:01
  • I've finally had a chance to look at this, but now I'm not sure which configuration file you're referring to. This looks like it's part of Maven configuration? If so, I'm not sure how Maven fits in. – Steve Sether May 26 '15 at 20:56