我有一个使用Hibernate 3.6.6.Final(来自JBoss6)的传统Ear-Project。 现在我想把那个Ear部署到Wildfly 8.0.0.Final。
我做了这里提到的所有事情:Sharing the Hibernate 3.5 or greater JPA persistence provider between multiple applications
我的persistence.xml如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="pu">
<description></description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/OracleDS</jta-data-source>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
<property name="hibernate.session_factory_name" value="hibernate/HelperSessionFactory" />
<property name="hibernate.session_factory_name_is_jndi" value="true" />
</properties>
</persistence-unit>
</persistence>
我将Dependencies: org.hibernate:3
添加到MANIFEST.MF
但部署失败并出现以下错误:
17:03:13,125 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 52) MSC000001: Failed to start service jboss.persistenceunit."HelperEJB.ear/HelperEJB.jar#pu": org.jboss.msc.service.StartException in service jboss.persistenceunit."HelperEJB.ear/HelperEJB.jar#pu": javax.persistence.PersistenceException: [PersistenceUnit: pu] Unable to instantiate Scanner class: class org.jboss.as.jpa.hibernate3.HibernateAnnotationScanner
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0]
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.8.0]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: pu] Unable to instantiate Scanner class: class org.jboss.as.jpa.hibernate3.HibernateAnnotationScanner
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1225)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.locateOrBuildScanner(EntityManagerFactoryBuilderImpl.java:767)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.scan(EntityManagerFactoryBuilderImpl.java:720)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:219)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:186)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:45)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:57)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:150)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:67) [hibernate-entitymanager.jar:3.6.6.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
... 8 more
Caused by: java.lang.ClassCastException: org.jboss.as.jpa.hibernate3.HibernateAnnotationScanner cannot be cast to org.hibernate.jpa.boot.scan.spi.Scanner
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.locateOrBuildScanner(EntityManagerFactoryBuilderImpl.java:764)
... 18 more