如何在Jboss v6上使用Spring EclipseLink jpa运行Web应用程序

我正在尝试使用EclipseLink学习Spring JPA . 我已经运行了独立的Spring webApplication,它只显示了一些JSP页面 .

在另一个eclipse项目中,我有一个简单的eclipseLink JPA示例 . 但是当我尝试将Spring WebApp与eclipselink代码集成时,它无法启动,因为jboss尝试加载hibernate而不是eclipseLink .

下面是错误 - 我想,我错过了在Jboss 6上使用Spring EclipseLink部署简单WebApp的一些基本步骤 . 这纯粹是出于学习目的 . 我用Google搜索,但没有足够的例子来说明这种组合 .

11:17:31,272 INFO [org.hibernate.ejb.Ejb3Configuration](ServerService线程池 - 50)HHH000204:处理PersistenceUnitInfo [name:Eclipselink_JPA ...] 11:17:31,384 WARN [org.hibernate.service.jdbc .connections.internal.ConnectionProviderInitiator](ServerService线程池 - 50)HHH000181:遇到没有合适的连接提供者,假设应用程序将提供连接11:17:31,405 ERROR [org.jboss.msc.service.fail](ServerService线程池) - 50)MSC000001:无法启动服务jboss.persistenceunit . “HelloWeb.war#Eclipselink_JPA”:服务jboss.persistenceunit中的org.jboss.msc.service.StartException . “HelloWeb.war#Eclipselink_JPA”:javax.persistence.PersistenceException :[PersistenceUnit:Eclipselink_JPA]无法在java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)[rt.jar]的org.jboss.as.jpa.service.PersistenceUnitServiceImpl $ 1.run(PersistenceUnitServiceImpl.java:103)上构建EntityManagerFactory :java.util.concurrent.Th:1.8.0_102] readPoolExecutor $ Worker.run(未知来源)[rt.jar:1.8.0_102] at java.lang.Thread.run(未知来源)[rt.jar:1.8.0_102] at org.jboss.threads.JBossThread.run( JBossThread.java:122)[jboss-threads-2.1.2.Final-redhat-1.jar:2.1.2.Final-redhat-1]引起:javax.persistence.PersistenceException:[PersistenceUnit:Eclipselink_JPA]无法构建位于org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900)的org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:925)中的EntityManagerFactory位于org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java: 76)在org.jboss的org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access $ 600(PersistenceUnitServiceImpl.java:57)的org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) . as.jpa.service.PersistenceUnitServiceImpl $ 1.run(PersistenceUnitServiceImpl.java:99)... 4更多Ca使用者:org.hibernate.HibernateException:当'hibernate.dialect'未在org.hibernate.service的org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:98)中设置时,Connection不能为null位于org.hibernate.service.internal.StandardServiceRegistryImpl.configureService的org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:174)中的.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68) (StandardServiceRegistryImpl.java:85)位于org.hibernate的org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) . cfg.Configuration.buildTypeRegistrations(Configuration.java:1827)org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1785)org.hibernate.ejb.EntityManagerFactoryImpl . (EntityManagerFactoryImpl.java:96)在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)... 9更多11:17:31,415 ERROR [org.jboss.as.controller.management-operation](控制器启动线程)JBAS014612:操作( “deploy”)失败 - 地址:([(“deployment”=>“HelloWeb.war”)]) - 失败描述:{“JBAS014671:失败的服务”=> {“jboss.persistenceunit . \”HelloWeb.war#Eclipselink_JPA \“”=>“服务jboss.persistenceunit中的org.jboss.msc.service.StartException . ”HelloWeb.war#Eclipselink_JPA \“:javax.persistence.PersistenceException:[PersistenceUnit:Eclipselink_JPA]无法构建EntityManagerFactory引起:javax .persistence.PersistenceException:[PersistenceUnit:Eclipselink_JPA]无法构建EntityManagerFactory引起:org.hibernate.HibernateException:连接不能是'hibernate.dialect'未设置“}}时为null

回答(2)

2 years ago

您提到 Spring EclipseLink 作为JPA提供程序,但日志显示 Hibernate 例外 . 你是"mixing" EclipseLinkHibernate . 你还可以发布你的 JPA 相关属性和 Spring beans配置吗?

2 years ago

我通过在persistence.xml中添加以下属性来解决这个问题 - org.eclipse.persistence.jpa.PersistenceProvider

现在,当我在Jboss上部署我的webApp时,它使用eclipseLink JPA加载EntityManagerFactory而不是默认的Hibernate .