Я только что обновил с Hibernate 4.2.19 до Hibernate 5.1.2. Конечно, мало что сказать, что все идет не так, как планировалось. После решения ряда вопросов (среди которых JOIN FETCH должны были быть заменены JOIN), я теперь работать в следующем номере:Невозможно получить доступ к TransactionManager или UserTransaction после обновления до Hibernate 5
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'idolConfig': Invocation of init method failed; nested exception is org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException: Unable to access TransactionManager or UserTransaction to make physical transaction delegate
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1575)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
[...]
Caused by: org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException: Unable to access TransactionManager or UserTransaction to make physical transaction delegate
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.makePhysicalTransactionDelegate(JtaTransactionCoordinatorImpl.java:229)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.getTransactionDriverControl(JtaTransactionCoordinatorImpl.java:203)
at org.hibernate.engine.transaction.internal.TransactionImpl.<init>(TransactionImpl.java:36)
at org.hibernate.internal.AbstractSessionImpl.getTransaction(AbstractSessionImpl.java:313)
at org.hibernate.internal.SessionImpl.<init>(SessionImpl.java:281)
at org.hibernate.internal.SessionFactoryImpl$SessionBuilderImpl.openSession(SessionFactoryImpl.java:1326)
at org.hibernate.jpa.internal.EntityManagerImpl.internalGetSession(EntityManagerImpl.java:133)
[...]
Журналы показывают, что JtaPlatform не может быть загружен:
2016-11-14 15:34:22,853 DEBUG .o.j.EntityManagerFactoryUtils - Line {272} Opening JPA EntityManager
2016-11-14 15:34:22,973 DEBUG e.t.j.p.i.JtaPlatformInitiator - Line {42} No JtaPlatform was specified, checking resolver
2016-11-14 15:34:22,973 DEBUG e.t.j.p.i.JtaPlatformInitiator - Line {42} No JtaPlatform was specified, checking resolver
2016-11-14 15:34:22,974 DEBUG i.JtaPlatformResolverInitiator - Line {33} No JtaPlatformResolver was specified, using default [org.hibernate.engine.transaction.jta.platform.internal.StandardJtaPlatformResolver]
2016-11-14 15:34:22,974 DEBUG i.JtaPlatformResolverInitiator - Line {33} No JtaPlatformResolver was specified, using default [org.hibernate.engine.transaction.jta.platform.internal.StandardJtaPlatformResolver]
2016-11-14 15:34:22,992 DEBUG .i.StandardJtaPlatformResolver - Line {101} Could not resolve JtaPlatform, using default [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2016-11-14 15:34:22,992 DEBUG .i.StandardJtaPlatformResolver - Line {101} Could not resolve JtaPlatform, using default [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2016-11-14 15:34:22,994 DEBUG .JtaTransactionCoordinatorImpl - Line {258} JtaPlatform#retrieveTransactionManager returned null
2016-11-14 15:34:22,994 DEBUG .JtaTransactionCoordinatorImpl - Line {258} JtaPlatform#retrieveTransactionManager returned null
2016-11-14 15:34:22,995 DEBUG .JtaTransactionCoordinatorImpl - Line {223} Unable to access TransactionManager, attempting to use UserTransaction instead
2016-11-14 15:34:22,995 DEBUG .JtaTransactionCoordinatorImpl - Line {223} Unable to access TransactionManager, attempting to use UserTransaction instead
2016-11-14 15:34:22,995 DEBUG .JtaTransactionCoordinatorImpl - Line {241} JtaPlatform#retrieveUserTransaction returned null
2016-11-14 15:34:22,995 DEBUG .JtaTransactionCoordinatorImpl - Line {241} JtaPlatform#retrieveUserTransaction returned null
У меня нет файла persistence.xml
. Вот мой spring.xml
:
<bean id="entityManagerFactoryEcli"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="commonUnit" />
<property name="dataSource" ref="dataSourceEcli" />
<property name="packagesToScan"
value="org.my.common.portal.domain,eu.cec.justice.common.domain.entity" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="javax.persistence.transactionType">jta</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</prop>
<prop key="hibernate.current_session_context_class">org.hibernate.context.internal.JTASessionContext</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">org.my.common.util.ECLICommonEhCacheRegionFactory</prop>
</props>
</property>
</bean>
<bean id="entityManagerFactoryCommon"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="portalUnit" />
<property name="dataSource" ref="dataSourceCommon" />
<property name="packagesToScan"
value="eu.cec.justice.common.domain.entity" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="javax.persistence.transactionType">jta</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</prop>
<prop key="hibernate.current_session_context_class">org.hibernate.context.internal.JTASessionContext</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">org.my.common.util.ECLICommonEhCacheRegionFactory</prop>
<prop key="hibernate.ejb.cfgfile">hibernate.cfg.xml</prop>
</props>
</property>
</bean>
<bean id="dataSourceCommon" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="$${portal.common.database.jndi}" />
<property name="resourceRef" value="true" />
</bean>
<bean id="dataSourceEcli" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="$${ecli.database.jndi}" />
<property name="resourceRef" value="true" />
</bean>
<tx:jta-transaction-manager />
<tx:annotation-driven/>
EDIT:
Добавление следующих к свойствам боба не решить мою проблему (я также понижен до Hibernate 5.0.0, но до сих пор проблема не решена):
<prop key="hibernate.transaction.coordinator_class">org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl</prop>
Это также не работает:
<prop key="hibernate.transaction.coordinator_class">jta</prop>
Это также удаление
<prop key="javax.persistence.transactionType">jta</prop>
но это не удалось.
Попробуйте [this] (http://stackoverflow.com/questions/32505969/hibernate-unable-to-access-transactionmanager-or-usertransaction-to-make-physic) и посмотрите, что произошло? – xsalefter
Нет, это не сработало. Обратите внимание, что у меня нет 'persistence.xml'. –