Here's the exception I get:
2014-11-29 13:40:30,902 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."myapp.war".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myapp.war".FIRST_MODULE_USE: JBAS018733: Failed to process phase FIRST_MODULE_USE of deployment "myapp.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:1145) [rt.jar:1.7.0_60] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60] Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011426: Could not deploy application packaged persistence provider 'org.hibernate.jpa.HibernatePersistenceProvider' 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.jpa.HibernatePersistenceProvider at java.lang.Class.asSubclass(Class.java:3165) [rt.jar:1.7.0_60] at org.jboss.as.jpa.processor.PersistenceProviderHandler.deploy(PersistenceProviderHandler.java:74) ... 7 more
As you can see, the deployment scanner is trying to do something with JPA, and failing.
Okay, I've been able to get past this by moving the JPA descriptors out of the META-INF directory. Simply renaming them, as the documentation suggests (e.g. jpa-persistence.xml) did not work.
I'll comment on the documentation.
1 of 1 people found this helpful
If the persistence unit definition, has jboss.as.jpa.managed set to false, the JPA container/subsystem will not deploy the persistence unit. This doesn't impact injection though (@PersistenceUnit will still lookup the persistence unit). Not sure if that helps you at all.
Thanks. I'll give that a try. Since I've moved the descriptor, things get a little further. However, it's not finding my entities now. The named queries fail to initialize because of that. Also odd is that the Hibernate logs are showing up in WildFly's server.log file, even though I am trying to use the application bundled log4j2.
That's probably a classloader issue I'm guessing. Under Tomcat this all works fine, BTW.
Maybe it would be better for me to just switch to a container managed persistence unit?
Using a container managed persistence unit is the well travelled path and will be easier to deal with. Others have gone through the extra effort (configuration/code changes) to use Spring, so some are also using Spring managed persistence units (helpful if there are Spring features that you need to use).
Okay, the documentation here: Spring applications development and migration guide - WildFly 8 - Project Documentation Editor has a few glitches:
- The <persistence-context-ref> example has an incorrect close tag. It should be </persistence-context-ref-name>
- Spring's PersistenceAnnotationBeanPostProcessor wants the EntityManager in a bean with the same name as the persistence unit, but the Spring JpaTransactionManager wants the EntityManagerFactory. Maybe I should just use JTA? Anyway, I'm having to declare both in web.xml and applicationContext.xml. That's kinda weird.
This may be coming too late. I had similar issues. I did some research and solved the issue. I posted the solution on stackoverflow. Below is the link.