>>>>>>>>>>>>>>>>
org.hibernate.transaction.JDBCTransaction toggleAutoCommit Could not toggle autocommit
java.sql.SQLException: DSRA9350E: Operation setAutoCommit is not allowed during a global transaction.
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.setAutoCommit(WSJdbcConnection.java:2414)
at org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(JDBCTransaction.java:194)
at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:142)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
at com.aoc.judiciary.framework.daoImpl.TestDaoImpl.getInfo(TestDaoImpl.java:69)
at com.aoc.judiciary.framework.ejb.BeantestingBean.retrieveInfo(BeantestingBean.java:95)
at com.aoc.judiciary.framework.ejb.EJSLocalStatelessBeantesting_f63227a0.retrieveInfo(EJSLocalStatelessBeantesting_f63227a0.java:29)
at com.aoc.judiciary.framework.delegateImpl.LocalTestDelegateImpl.retrieveInfo(LocalTestDelegateImpl.java:74)
at com.aoc.judiciary.framework.ActionClasses.Action1.retrieve(Action1.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
and intrestingly when i dont write the "session.getTransaction().commit() " statement , there are no exceptions on console.
any one encountered this situation in their project?
thanks
J
Java
Last Comment
jaggernat
8/22/2022 - Mon
NHBFighter
Did you define "hibernate.transaction.factory_class" in your Hibernate config and, if so what value did you give it?
What kind of env are you running in. Is this a web app running on weblogic, is it standalone? What kind of JDBC driver are you using, is it an XA datasource. This error usually surfaces when you are running the code with in the context of another transaction. IE a container managed transaction, like from within a EJB, and in that case the container is supposed to manage all the committing and rolling back of transactions.
i am using websphere application server 6.0 with Db2
It is a web application
Driver : DB2 Legacy CLI-based Type 2 JDBC Driver
I am not using XA datasource but i am using COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource
In my ejb i am using container mananged trnasaction (the default) where
transaction-type is set to container like this : <transaction-type>Container</transaction-type>
thanks
NHBFighter
If you are calling you DAO from with in an EJB you should not be worrying about transaction management within your DAO (IE you shouldn't start or commit a transaction) that is the containers job. So you can remove the begin transaction and commit transaction code.
jaggernat
ASKER
If i remove the begin transaction code i get this error
org.hibernate.HibernateException: getNamedQuery is not valid without active transaction
although if i keep session.beginTransaction(); and comment out just session.getTransaction().commit();
everything works fine without any problems
NHBFighter
Ok lets see if this works:
in your config file try this has your session factory:
<session-factory>
<property name="connection.datasource">familyDb</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.DB2390Dialect</property>
<property name="current_session_context_class">jta</property>
<property name="transaction.manager_lookup_class">
org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<mapping resource="spResourceMapping/TestVO.hbm.xml"/>
</session-factory>
And try the code with out the beginTransaction().
jaggernat
ASKER
hmm, get this error now
>>>>>>>>>>>>>>>>>>>>>>>>>>>
Exception data: org.hibernate.TransactionException: could not register synchronization with JTA TransactionManager
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:181)
at org.hibernate.jdbc.JDBCContext.<init>(JDBCContext.java:76)
at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:213)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:525)
at org.hibernate.context.JTASessionContext.buildOrObtainSession(JTASessionContext.java:114)
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:80)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:542)
at com.aoc.judiciary.framework.daoImpl.TestDaoImpl.getInfo(TestDaoImpl.java:50)
at com.aoc.judiciary.framework.ejb.BeantestingBean.retrieveInfo(BeantestingBean.java:95)
at com.aoc.judiciary.framework.ejb.EJSLocalStatelessBeantesting_f63227a0.retrieveInfo(EJSLocalStatelessBeantesting_f63227a0.java:29)
at com.aoc.judiciary.framework.delegateImpl.LocalTestDelegateImpl.retrieveInfo(LocalTestDelegateImpl.java:74)
at com.aoc.judiciary.framework.ActionClasses.Action1.retrieve(Action1.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1282)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:673)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2933)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1912)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:84)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:619)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1462)
Caused by: java.lang.UnsupportedOperationException
at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter.getStatus(WebSphereExtendedJTATransactionLookup.java:78)
at org.hibernate.transaction.JTATransactionFactory.isTransactionInProgress(JTATransactionFactory.java:94)
at org.hibernate.jdbc.JDBCContext.isTransactionInProgress(JDBCContext.java:187)
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:159)
[5/31/07 15:37:37:912 EDT] 00000039 DatasourceCon I org.hibernate.connection.DatasourceConnectionProvider configure Using datasource: familyDb
>>>>>>>>>>>>>>>>
and then hangs, doesnt print anything after that
NHBFighter
I'm not sure this has anything to do with the new confic xml snipit I sent you. If you roll back to the old one does it work? the only thing that should have changed was:
<property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
to
<property name="transaction.factory_class">
org.hibernate.transaction.CMTTransactionFactory
</property>
jaggernat
ASKER
org.hibernate.transaction.CMTTransactionFactory works perfectly
so if i am using bean managed transactions(using JTA) or container managed transactions (using ejb container), i am not supposed to use session.beginTransaction() and session.getTransaction().commit(). Is that correct?