title: Migrate Hibernate 4.3 to 5 : TransactionManagerDelegate cannot be cast to TransactionManager
body: <p>I try to migrate my hibernate 4.3 project to 5.X.</p>
  <p>I have theses dependencies :</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
      &lt;version&gt;4.2.0.Final&lt;/version&gt;
      &lt;exclusions&gt;
          &lt;exclusion&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;/exclusion&gt;
      &lt;/exclusions&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
      &lt;version&gt;5.0.11.Final&lt;/version&gt;
      &lt;exclusions&gt;
          &lt;exclusion&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
              &lt;artifactId&gt;jta&lt;/artifactId&gt;
              &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
              &lt;artifactId&gt;jboss-transaction-api_1.2_spec&lt;/artifactId&gt;
              &lt;groupId&gt;org.jboss.spec.javax.transaction&lt;/groupId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
              &lt;artifactId&gt;jboss-logging&lt;/artifactId&gt;
              &lt;groupId&gt;org.jboss.logging&lt;/groupId&gt;
          &lt;/exclusion&gt;
      &lt;/exclusions&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;artifactId&gt;jboss-logging&lt;/artifactId&gt;
      &lt;groupId&gt;org.jboss.logging&lt;/groupId&gt;
      &lt;version&gt;3.2.0.Final&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-c3p0&lt;/artifactId&gt;
      &lt;version&gt;5.0.11.Final&lt;/version&gt;
      &lt;exclusions&gt;
          &lt;exclusion&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;/exclusion&gt;
      &lt;/exclusions&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>I also have spring-orm 4.2.9 used for connection.</p>
  <p>I replace :</p>
  <pre><code>&lt;bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate4.LocalSessionFactoryBean&quot;&gt;
  </code></pre>
  <p>By :</p>
  <pre><code>&lt;bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate5.LocalSessionFactoryBean&quot;&gt;
  </code></pre>
  <p>In my datasource.xml files, but when the server start, it load a little and then I have this error :</p>
  <pre><code>2022-06-08 16:24:31,335 ERROR [STDERR] java.lang.ClassCastException: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate cannot be cast to javax.transaction.TransactionManager
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform.locateTransactionManager(JBossAppServerJtaPlatform.java:42)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.retrieveTransactionManager(AbstractJtaPlatform.java:87)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.getTransactionManager(AbstractJtaPlatform.java:98)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerBasedSynchronizationStrategy.canRegisterSynchronization(TransactionManagerBasedSynchronizationStrategy.java:39)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.canRegisterSynchronization(AbstractJtaPlatform.java:131)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.pulse(JtaTransactionCoordinatorImpl.java:141)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.&lt;init&gt;(JtaTransactionCoordinatorImpl.java:92)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildTransactionCoordinator(JtaTransactionCoordinatorBuilderImpl.java:28)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.internal.SessionImpl.&lt;init&gt;(SessionImpl.java:274)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.internal.SessionFactoryImpl$SessionBuilderImpl.openSession(SessionFactoryImpl.java:1332)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at org.hibernate.internal.SessionFactoryImpl.openSession(SessionFactoryImpl.java:684)
  2022-06-08 16:24:31,336 ERROR [STDERR]  at com.al6.jtob.data.dao.GenericHibernateDAO.getSession(GenericHibernateDAO.java:75)
  </code></pre>
  <p>How can I investigate this ?</p>