Hi all,
I have jus tried to create my first Hibernate example (simple servlet) using JTA and I cannot get it work..
My question is simply: Do I need to to begin and commit the hibernate Transactions when using JTATransactionFactory?
The problem is that, when using the idiom:
Code:
Session session = factory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
// do some work
...
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
session.close();
}
I always get this annoying exception in the session.close():
Code:
2003-12-02 15:32:43,937 [DEBUG] impl.SessionImpl closing session
2003-12-02 15:32:43,937 [DEBUG] impl.SessionImpl disconnecting session
2003-12-02 15:32:43,937 [ERROR] util.JDBCExceptionReporter Cannot close connection
java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:116)
at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:125)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:67)
at weblogic.jdbc.wrapper.JTSConnection_oracle_jdbc_driver_OracleConnection.getWarnings(Unknown Source)
at net.sf.hibernate.impl.SessionFactoryImpl.closeConnection(SessionFactoryImpl.java:404)
at net.sf.hibernate.impl.SessionImpl.disconnect(SessionImpl.java:2946)
at net.sf.hibernate.impl.SessionImpl.close(SessionImpl.java:438)
at com.sonynetservices.hibernate.manager.HibernateManager.closeSession(HibernateManager.java:105)
It seems that session.close() tries to commit the transaction again.. Is this normal? Do I need to configure anything in the application server?
I'm using hibernate 2.0.3 in Weblogic 8.1 with an Oracle8 DB, my entries in hibernate config.xml related to transactions look like:
Code:
<!-- db -->
<property name="connection.datasource">hibernateDataSource</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<!-- transactions -->
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">net.sf.hibernate.transaction.WeblogicTransactionManagerLookup</property>
NOTE: Using JDBCTransactionManager works pretty well..
thanks in advance,
Ruben
[quote][/quote]