1 Reply Latest reply on May 22, 2006 2:07 AM by sean liu

    org.hibernate.StaleObjectStateException when retrieving the

    sean liu Newbie

      I had the following exception when the system tried to retrieve the task list of some groups.
      It seems that hibernate first update the objects in session before sending the queries to ask the task list and it tried to update the token. But i wondered why that happened, cause the system just query the database and i have a interceptor that can get a new jbpmContext before the business method and close the jbpmContext after the business method.

      Any advices are welcome and thanks in advance.

      2006-05-15 10:24:29,882 ERROR [-->Catch Exception: ] ERR_USER_ASSIGNMENT userId: operator1 Failed
      com.wxxr.worklist.model.BizProcessException: Caught Throwable when try to retrieve worklist for user :operator1
      at com.wxxr.workflow.jbpm.JbpmEngine.getWorkListOfUsers(JbpmEngine.java:687)
      at com.wxxr.workflow.jbpm.JbpmEngineService.getWorkListOfUsers(JbpmEngineService.java:181)
      at sun.reflect.GeneratedMethodAccessor146.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at com.wxxr.workflow.jbpm.ContextInterceptor.invoke(ContextInterceptor.java:56)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.system.server.jmx.LazyMBeanServer.invoke(LazyMBeanServer.java:225)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy1255.getWorkListOfUsers(Unknown Source)
      at com.wxxr.worklist.ejb.WorklistControllerImpl.getWorkListOfUsers(WorklistControllerImpl.java:107)
      at sun.reflect.GeneratedMethodAccessor145.invoke(Unknown Source)
      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:149)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      at com.wxxr.common.jboss.EjbInvokerInterceptor.invoke(EjbInvokerInterceptor.java:79)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
      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 sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
      at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
      at $Proxy159.getWorkListOfUsers(Unknown Source)
      at com.wxxr.web.worklist.util.AssignmentTool.getUserAssignment(AssignmentTool.java:161)
      at com.wxxr.web.worklist.presentation.SearchMenuRenderer.doPropertyConf(SearchMenuRenderer.java:59)
      at com.wxxr.web.worklist.presentation.AbstractMenuRenderer.renderMenu(AbstractMenuRenderer.java:60)
      at com.hygensoft.framework.frontend.security.DefaultMenuRenderer.doRendering(DefaultMenuRenderer.java:52)
      at com.hygensoft.framework.frontend.presentation.FieldTag.doAfterBody(FieldTag.java:60)
      at org.apache.jsp.jsp.U2_jsp._jspx_meth_hg_menu_7(org.apache.jsp.jsp.U2_jsp:1224)
      at org.apache.jsp.jsp.U2_jsp._jspx_meth_hg_msgBox_6(org.apache.jsp.jsp.U2_jsp:1181)
      at org.apache.jsp.jsp.U2_jsp._jspService(org.apache.jsp.jsp.U2_jsp:176)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      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.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
      at com.hygensoft.framework.frontend.navigation.Navigator.forward(Navigator.java:235)
      at com.hygensoft.framework.frontend.navigation.Navigator.navigateTo(Navigator.java:162)
      at com.hygensoft.framework.frontend.action.RequestDispatcher.doNavigation(RequestDispatcher.java:302)
      at com.hygensoft.framework.frontend.action.RequestDispatcher.dispatch(RequestDispatcher.java:223)
      at com.wxxr.common.web.servlet.DispatchServlet.service(DispatchServlet.java:47)
      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 com.wxxr.web.worklist.servlet.FrequenceSubmitFilter.doFilter(FrequenceSubmitFilter.java:73)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at com.wxxr.common.web.filter.SecurityFilter.doFilter(SecurityFilter.java:82)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      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:159)
      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.jbpm.JbpmException: couldn't get pooled task instances list for actors '[AdsOperator, BusinessUser, WFUsers]'
      at org.jbpm.db.TaskMgmtSession.findPooledTaskInstances(TaskMgmtSession.java:122)
      at org.jbpm.JbpmContext.getGroupTaskList(JbpmContext.java:196)
      at com.wxxr.workflow.jbpm.JbpmEngine.getWorklistOfUser(JbpmEngine.java:586)
      at com.wxxr.workflow.jbpm.JbpmEngine.getWorkListOfUsers(JbpmEngine.java:678)
      ... 104 more
      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.graph.exe.Token#247]
      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1634)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2207)
      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2117)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2373)
      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
      at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
      at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:878)
      at org.hibernate.impl.SessionImpl.prepareQueries(SessionImpl.java:1071)
      at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1061)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1010)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
      at org.jbpm.db.TaskMgmtSession.findPooledTaskInstances(TaskMgmtSession.java:118)
      ... 107 more

        • 1. Re: org.hibernate.StaleObjectStateException when retrieving
          sean liu Newbie

          I think there are some problems in implementations of method JbpmContext.close.
          If jbpmContext.close() failed for some reason(in my case, when some exceptions are thrown, invoke setRollbackOnly, then jbpmContext.close), then jbpmContext will not be pushed out of stack of theadLocal varaible. And if anoter request be allocated the same thread, then the same jbpmContext will be retrieved from thread and the data(like hibernate session) remained in the last request maybe corrupt this request.