gpt4 book ai didi

spring - 从 JBoss AS 7.1.1 迁移到 EAP 6.2 导致 spring 定义的 entityManagerFactory 在加载时失败

转载 作者:行者123 更新时间:2023-12-01 23:56:17 25 4
gpt4 key购买 nike

我正在使用 JPA 2.1 和 spring 4.0.2 开发一个应用程序。 Jboss 服务器提供了一个 JNDI 数据源。

为了避免使用 persistence.xml 文件,我在 services.xml 中定义了这个 entityManager:

<jee:jndi-lookup id="projectDataSourceTaget" jndi-name="${jndi.datasourceName}"
expected-type="javax.sql.DataSource" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
depends-on="flyway">
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="packagesToScan" value="com.xxx" />
<property name="persistenceUnitName" value="projectEntityManager" />
<property name="jtaDataSource" ref="projectDataSourceTaget" />
<property name="jpaProperties">
<props>
<prop key="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.JBossTransactionManagerLookup
</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<!-- validate | update | create | create-drop -->
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="org.hibernate.envers.use_revision_entity_with_native_id">false</prop>
<prop key="javax.persistence.transactionType">JTA</prop>
</props>
</property>
</bean>

虽然这在 Jboss 7.1.1 中运行良好,但当更改为 EAP 6.2 时它无法初始化服务:

17:27:17,061 WARN  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (ServerService Thread Pool -- 48) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
17:27:17,079 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.persistenceunit."Project.war#Project": org.jboss.msc.service.StartException in service jboss.persistenceunit."Project.war#Project": javax.persistence.PersistenceException: [PersistenceUnit: Project] Unable to build EntityManagerFactory
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60-ea]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60-ea]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_60-ea]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: GaIA] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
... 4 more
Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:98)
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:174)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1822)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1780)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
... 9 more

我在想什么?我已经尝试对此配置进行多项更改,但似乎没有任何效果。也许 JBoss EAP 6.2 不支持 LocalContainerEntityManagerFactoryBean?

最佳答案

最后我遇到了问题:在项目的旧版本中,有一个 persistence.xml 定义,它在 JBoss 中部署了好几天,即使进行了干净的部署(我猜这是因为文件系统故障)。这使得 JBoss 加载器与 persistence.xml 和 services.xml 中定义的 entityManagers 混淆。

关于spring - 从 JBoss AS 7.1.1 迁移到 EAP 6.2 导致 spring 定义的 entityManagerFactory 在加载时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23546291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com