title: Unable to access TransactionManager or UserTransaction after updating to Hibernate 5
body: <p>I just updated from Hibernate 4.2.19 to Hibernate 5.1.2. Of course, little it is to say that things are not going as planned. After solving several issues (among which JOIN FETCH had to be replaced by JOIN), I now run into the next issue:</p>
  
  <pre><code>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.&lt;init&gt;(TransactionImpl.java:36)
      at org.hibernate.internal.AbstractSessionImpl.getTransaction(AbstractSessionImpl.java:313)
      at org.hibernate.internal.SessionImpl.&lt;init&gt;(SessionImpl.java:281)
      at org.hibernate.internal.SessionFactoryImpl$SessionBuilderImpl.openSession(SessionFactoryImpl.java:1326)
      at org.hibernate.jpa.internal.EntityManagerImpl.internalGetSession(EntityManagerImpl.java:133)
      [...]
  </code></pre>
  
  <p>The logs show that the JtaPlatform could not be loaded:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I do not have a <code>persistence.xml</code> file. Here is my <code>spring.xml</code>:</p>
  
  <pre><code>&lt;bean id="entityManagerFactoryEcli"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="commonUnit" /&gt;
      &lt;property name="dataSource" ref="dataSourceEcli" /&gt;
      &lt;property name="packagesToScan"
          value="org.my.common.portal.domain,eu.cec.justice.common.domain.entity" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="showSql" value="false" /&gt;
              &lt;property name="generateDdl" value="false" /&gt;
              &lt;property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="jpaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="javax.persistence.transactionType"&gt;jta&lt;/prop&gt;
              &lt;prop key="hibernate.transaction.manager_lookup_class"&gt;org.hibernate.transaction.WeblogicTransactionManagerLookup&lt;/prop&gt;
              &lt;prop key="hibernate.current_session_context_class"&gt;org.hibernate.context.internal.JTASessionContext&lt;/prop&gt;
              &lt;prop key="hibernate.cache.use_second_level_cache"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.cache.use_query_cache"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.cache.region.factory_class"&gt;org.my.common.util.ECLICommonEhCacheRegionFactory&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="entityManagerFactoryCommon"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="portalUnit" /&gt;
      &lt;property name="dataSource" ref="dataSourceCommon" /&gt;
      &lt;property name="packagesToScan"
          value="eu.cec.justice.common.domain.entity" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="showSql" value="false" /&gt;
              &lt;property name="generateDdl" value="false" /&gt;
              &lt;property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="jpaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="javax.persistence.transactionType"&gt;jta&lt;/prop&gt;
              &lt;prop key="hibernate.transaction.manager_lookup_class"&gt;org.hibernate.transaction.WeblogicTransactionManagerLookup&lt;/prop&gt;
              &lt;prop key="hibernate.current_session_context_class"&gt;org.hibernate.context.internal.JTASessionContext&lt;/prop&gt;
              &lt;prop key="hibernate.cache.use_second_level_cache"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.cache.use_query_cache"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.cache.region.factory_class"&gt;org.my.common.util.ECLICommonEhCacheRegionFactory&lt;/prop&gt;
              &lt;prop key="hibernate.ejb.cfgfile"&gt;hibernate.cfg.xml&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSourceCommon" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiName" value="$${portal.common.database.jndi}" /&gt;
      &lt;property name="resourceRef" value="true" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSourceEcli" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiName" value="$${ecli.database.jndi}" /&gt;
      &lt;property name="resourceRef" value="true" /&gt;
  &lt;/bean&gt;
  
  &lt;tx:jta-transaction-manager /&gt;
  &lt;tx:annotation-driven/&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Adding the following to the bean properties did not solve my issue (I also downgraded to Hibernate 5.0.0 but still the problem persists):</p>
  
  <pre><code>&lt;prop key="hibernate.transaction.coordinator_class"&gt;org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl&lt;/prop&gt;
  </code></pre>
  
  <p>This also didn't work:</p>
  
  <pre><code>&lt;prop key="hibernate.transaction.coordinator_class"&gt;jta&lt;/prop&gt;
  </code></pre>
  
  <p>This also deleting </p>
  
  <pre><code>&lt;prop key="javax.persistence.transactionType"&gt;jta&lt;/prop&gt;
  </code></pre>
  
  <p>but this failed as well.</p>