Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: Hibernate 3.1.2
Mapping documents: Not relevant
Code between sessionFactory.openSession() and session.close():
Code:
public void endActivityInstance(String user, int which, Collection results) throws UnavailableActivityInstanceException, InvalidResultsException {
Session session = HibernateUtil.getSession(); //- thread local session
Transaction xact = session.beginTransaction();
try {
updatePreviousUser(user, pf.getActivityInstance(which));
endActivityInstance(which, results); //- method setResults (shown below) is in call path
xact.commit(); //<<<----- EXCEPTION IS THROWN HERE
}
catch (Exception e) {
xact.rollback();
_LOG.warn("Could not commit transaction to end activity", e);
}
}
protected final void setResults(ItemSet items) throws InvalidResultsException {
Session session = HibernateUtil.getSession();
Transaction xact = null;
try {
if (items == null) {
throw new InvalidResultsException("Passed-in item set can not be null");
}
xact = session.beginTransaction(); //- nested in the transaction started in endActivityInstance
session.update(_items);
session.update(this);
xact.commit(xact);
}
catch (Exception e) {
xact.rollback();
throw new FailureException("Unable to save results of ActivityInstance #" + getWorkflowId(), e);
}
}
Full stack trace of any exception that occurs:Code:
2006-03-23 00:13:20,078 ERROR [com.imsweb.seerdms.app.workflow.buslogic.WorkflowWebBean] Could not commit transaction to end activity; already finished
com.imsweb.seerdms.app.workflow.base.AlreadyFinishedException: org.hibernate.TransactionException: Transaction not successfully started
at com.imsweb.seerdms.app.workflow.hibernate.HibernatePackageFactory.commit(HibernatePackageFactory.java:876)
at com.imsweb.seerdms.app.workflow.buslogic.WorkflowWebBean.endActivityInstance(WorkflowWebBean.java:535)
at com.imsweb.seerdms.app.workflow.buslogic.WorkflowWebSession.endActivityInstance(WorkflowWebSession.java:399)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:130)
at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
at $Proxy119.endActivityInstance(Unknown Source)
at com.imsweb.seerdms.web.edit.record.DisplayRecordUtils.endScreeningActivity(DisplayRecordUtils.java:667)
at com.imsweb.seerdms.web.edit.record.DisplayRecordAction.updateExit(DisplayRecordAction.java:933)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at com.imsweb.seerdms.web.shared.SeerAction.execute(SeerAction.java:118)
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:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.TransactionException: Transaction not successfully started
at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:126)
at com.imsweb.seerdms.app.workflow.hibernate.HibernatePackageFactory.commit(HibernatePackageFactory.java:872)
... 57 more
Name and version of the database you are using: Oracle 10g
The generated SQL (show_sql=true): Not relevant
Debug level Hibernate log excerpt: In the code above, JTATransaction throws a TransactionException and probably shouldn't. The problem appears to be in the code below from JTATransaction:
Code:
private void afterCommitRollback() throws TransactionException {
begun = false;
if (callback) { // this method is a noop if there is a Synchronization!
if (!newTransaction) {
log.warn("You should set hibernate.transaction.manager_lookup_class if cache is enabled");
}
int status=NULL;
try {
status = ut.getStatus();
}
catch (Exception e) {
log.error("Could not determine transaction status after commit", e);
throw new TransactionException("Could not determine transaction status after commit", e);
}
finally {
/*if (status!=Status.STATUS_COMMITTED && status!=Status.STATUS_ROLLEDBACK) {
log.warn("Transaction not complete - you should set hibernate.transaction.manager_lookup_class if cache is enabled");
//throw exception??
}*/
jdbcContext.afterTransactionCompletion(status==Status.STATUS_COMMITTED, this);
}
}
}
This method is called after the commit() method and the problematic line is "begun = false;". Begun is set to false after the commit of the nested transaction.
Then when the original transaction calls commit, it looks as if the transaction was never started because begun is set to false. I'm not sure where begun should be
reset at, but it probably shouldn't be here. I wanted to get others thoughts before posting this as a bug.