Error when calling beginTrasaction : IllegalStateException: A JTA EntityManager cannot use getTransaction() on EAP 7

Solution Verified - Updated -

Issue

We are migrating our application from jboss eap 6.1 to EAP 7.2
When session.beginTrasaction() is called, we are getting below exception:
ERROR [stderr] (default task-5) java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

Session factory is being created as:

Object obj = context.lookup("java:/hibernate/ServicesManagementHibernateV2Factory");
SessionFactory sessions = (SessionFactory)obj;

The below is the persistence.xml file of the custom jar.

<persistence-unit name="ServicePU">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/OracleDS</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="jboss.as.jpa.providerModule" value="org.hibernate" />
<property name="hibernate.session_factory_name" value="java:/hibernate/ServicesHibernateV2Factory"/>
<property name="hibernate.id.new_generator_mappings" value="true" />
<property name="hibernate.cache.use_second_level_cache" value="false"/>
<property name="hibernate.cache.use_query_cache" value="false"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="hibernate.transaction.factory_class" value="org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory" />
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
</properties>
</persistence-unit>

Since, factory_class property was deprecated in hibernate-core of 5.3.7.Final-redhat-00001, we removed it. But, still the issue persists.

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In