迁移到jboss wildfly

时间:2014-11-25 14:26:34

标签: java hibernate jboss wildfly

我尝试将我的应用程序从jonas迁移到JBoss WildFly 8.我面临以下错误:

14:30:49,518 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.persistenceunit."myAppEar.ear/myAppMetier.jar#myApp": org.jboss.msc.service.StartException in service jboss.persistenceunit."myAppEar.ear/myAppMetier.jar#myApp": java.lang.NullPointerException
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
   at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_25]
   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.1.0.Final.jar:8.1.0.Final]
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
   at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
   at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.NullPointerException
   at org.jboss.as.naming.WritableServiceBasedNamingStore.rebind(WritableServiceBasedNamingStore.java:120)
   at org.jboss.as.naming.NamingContext.rebind(NamingContext.java:274)
   at org.jboss.as.naming.InitialContext$DefaultInitialContext.rebind(InitialContext.java:269)
   at javax.naming.InitialContext.rebind(InitialContext.java:431) [rt.jar:1.7.0_25]
   at javax.naming.InitialContext.rebind(InitialContext.java:431) [rt.jar:1.7.0_25]
   at org.hibernate.util.NamingHelper.bind(NamingHelper.java:97) [hibernate3.jar:3.6.10.Final]
   at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:113) [hibernate3.jar:3.6.10.Final]
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:367) [hibernate3.jar:3.6.10.Final]
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872) [hibernate3.jar:3.6.10.Final]
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906) [hibernate3.jar:3.6.10.Final]
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) [hibernate3.jar:3.6.10.Final]
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
   ... 8 more

我将wildfly配置为在persistence.xml中使用hibernate 3.6

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
   <persistence-unit name="myApp" transaction-type="JTA">
         <provider>org.hibernate.ejb.HibernatePersistence</provider>
         <jta-data-source>nfsbdd</jta-data-source>

         <exclude-unlisted-classes>true</exclude-unlisted-classes>

         <properties>
                <property name="hibernate.hbm2ddl.auto" value="validate"/>
                <property name="hibernate.ejb.cfgfile" value="META-INF/hibernate.cfg.xml"/>
                <property name="jboss.as.jpa.providerModule" value="org.hibernate:3"/>
         </properties>

   </persistence-unit>

应用程序使用hibernate3.6,ejb3.0,jsf 2.1运行。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:1)

你的hibernate 3.6与来自wildfly的hibernate 4.3.8冲突。如果您没有使用hibernate指定的注释和函数,那么迁移到JPA会更好。好的解决方案,但并不完美,是迁移到休眠4.3.8。什么变体不那么痛苦,取决于您的应用程序代码和架构。