weblogic XA 事務配置問題

天下為公發表於2004-12-30
環境: weblogic 8.1
DB: oralce 9.02
使用hibernate 配合jndi
當在控制檯中選擇
oracle.jdbc.xa.client.OracleXADataSource 驅動程式以支援XA
結果啟動應用 出現錯誤

51964 [ExecuteThread: '13' for queue: 'weblogic.kernel.Default'] ERROR net.sf.hibernate.util.JDBCExc
eptionReporter(38) - SQLException occurred
java.sql.SQLException: SQL operations are not allowed with no global transaction by default for XA d
rivers. If the XA driver supports performing SQL operations with no global transaction, explicitly a
llow it by setting "SupportsLocalTransaction" JDBC connection pool property to true. In this case, a
lso remember to complete the local transaction before using the connection again for global transact
ion, else a XAER_OUTSIDE XAException may result. To complete a local transaction, you can either set
 auto commit to true or call Connection.commit() or Connection.rollback().
        at weblogic.jdbc.wrapper.JTAConnection.checkIfLocalTxSupported(JTAConnection.java:85)
        at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:74)
        at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:316)
        at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:257)
        at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:232)
        at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
        at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
        at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
        at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
        at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
        at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
        at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:118)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3613)
        at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)

 

如果配置 允許本地事務 則

ceptionReporter(46) - XA error: XAER_PROTO : Routine was invoked in an inproper context start() fail
ed on resource 'MyJDBC Connection Pool-1': XAER_PROTO : Routine was invoked in an inproper context
javax.transaction.xa.XAException
        at oracle.jdbc.xa.OracleXAResource.disallowLocalTxnMode(OracleXAResource.java:1047)
        at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:153)
        
        
        
        139540 [ExecuteThread: '13' for queue: 'weblogic.kernel.Default'] ERROR net.sf.hibernate.util.JDBCEx
ceptionReporter(38) - Could not execute query
java.sql.SQLException: SQL operations are not allowed with no global transaction by default for XA d
rivers. If the XA driver supports performing SQL operations with no global transaction, explicitly a
llow it by setting "SupportsLocalTransaction" JDBC connection pool property to true. In this case, a
lso remember to complete the local transaction before using the connection again for global transact
ion, else a XAER_OUTSIDE XAException may result. To complete a local transaction, you can either set
 auto commit to true or call Connection.commit() or Connection.rollback().
 

相關文章