Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate error : Could not turn on auto-commit in an active global transaction

I'm getting an error while deploying our application.

The environmet is :

  • Jboss 7.1.3+Hibernate 4 + JPA
  • OJDBC : ojdbc6.jar

The stacktrace is as below,

09:13:30,703 WARN  [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] (ServerService Thread Pool -- 127) HHH000341: Could not obtain connection metadata : could not turn on auto-commit in an active global transaction
09:13:30,703 INFO  [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (ServerService Thread Pool -- 127) HHH000422: Disabling contextual LOB creation as connection was null
09:13:30,704 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 127) MSC00001: Failed to start service jboss.persistenceunit."css-ear-0.5.3-SIT.ear/css-submission-0.5.3-SIT.war#css-submission-PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."css-ear-0.5.3-SIT.ear/css-submission-0.5.3-SIT.war#css-submission-PU": java.lang.NullPointerException
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:100) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]
Caused by: java.lang.NullPointerException
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:207)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:73)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2279)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2275)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:197) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$500(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:96) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final

The datasource configuration in standalone.xml is,

<xa-datasource jta="true" jndi-name="java:jboss/datasources/PsaDS" pool-name="PsaDS" enabled="true" use-java-context="true" use-ccm="true">
  <xa-datasource-property name="URL">
        jdbc:oracle:thin:@<hsot>
  </xa-datasource-property>
  <driver>oracle</driver>
  <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
  <xa-pool>
        <min-pool-size>2</min-pool-size>
        <max-pool-size>50</max-pool-size>
        <prefill>true</prefill>
  </xa-pool>
  <security>
        <user-name>user</user-name>
        <password>pwd</password>
  </security>

The driver we are using is,

<drivers>
  <driver name="oracle" module="com.oracle.ojdbc6">
        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
  </driver></drivers>
like image 891
sk85 Avatar asked Oct 11 '13 06:10

sk85


1 Answers

Try making the following changes to your standalone.xml within your <xa-datasource> definition tags:

Add the following inside the <xa-pool> tag:

<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools>true</no-tx-separate-pools>

According to documentation:

no-tx-separate-pools: The presence of this element indicates that two connection pools are required to isolate connections used with JTA transaction from those used without a JTA transaction. The pools are lazily constructed on first use. Its use case is for Oracle (and possibly other vendors) XA implementations that don't like using an XA connection with and without a JTA transaction.

If that doesn't make it work alone, try also to add this in your <xa-datasource> definition:

<validation>
      <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
      <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
      <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
like image 173
David Bejar Avatar answered Oct 30 '22 05:10

David Bejar