[Design of JBoss jBPM] - TaskInstance.setActorId(String) seems to cause SQL deadlock
by Octomac
Hello, all.
I am implementing JBPM as part of a JSF application on a GlassFish server. Part of the project requires creating a series of Tasks, assigning those tasks to groups, and then allowing individuals from said groups to see a list of tasks they are eligible for, select one, and assign it to themselves. I have been attempting to use the TaskInstance.setActorId(String) method to change the ActorId property of the selected TaskInstance to the current user's login, but for some reason, this produces a series of exceptions.
I am not sure if I am maintaining the JbpmContext object(s) correctly, as well. Please take a look at the code below, and let me know if anything jumps out as blatantly incorrect. Thanks!
I have created a class called JBPMController to handle all of the JBPM-related functionality. The code to assign a task to a specific user is found there, and reproduced below:
| public void assignTask(String taskId, String userId)
| {
| long taskInstanceId = Long.parseLong(taskId);
| TaskInstance thisTask = jbpmContext.getTaskInstance(taskInstanceId);
| thisTask.setActorId(userId);
| }
|
That code is called from a Session-scope backing bean entitled ProcessController. The code to do so is reproduced below:
| public String assignTask() throws SQLException, ClassNotFoundException{
| try{
| controller.openJbpmContext();
| if(selectedTask != null && selectedTask != ""){
| int taskId = Integer.parseInt(selectedTask);
| controller.assignTask(selectedTask, uid);
| }
| }
| finally{
| controller.closeJbpmContext();
| }
| return("Set");
| }
|
The JbpmContext object is created and closed with calls to these two methods in the JBPMController class:
| public void openJbpmContext()
| {
| jbpmContext = jbpmConfiguration.createJbpmContext();
| }
|
| public void closeJbpmContext()
| {
| jbpmContext.close();
| }
|
The issue I'm experiencing is that the line "thisTask.setActorId(userId);" in my JBPMController class is causing the system to hang for up to five or six minutes, and then throwing the following error:
| org.hibernate.exception.GenericJDBCException: could not update: [org.jbpm.taskmgmt.exe.TaskInstance#93]
| at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
| at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
| at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
| at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
| at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
| at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
| at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
| at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
| at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
| at org.jbpm.persistence.db.DbPersistenceService.commit(DbPersistenceService.java:256)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:214)
| at org.jbpm.svc.Services.close(Services.java:225)
| at org.jbpm.JbpmContext.close(JbpmContext.java:139)
| at processes.JBPMController.closeJbpmContext(JBPMController.java:375)
| at net.bresnan.elemer.controller.ProcessController.assignTask(ProcessController.java:193)
| 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:597)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
| at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
| at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
| at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
| at javax.faces.component.UICommand.broadcast(UICommand.java:383)
| at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
| at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
| at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| at sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:276)
| at java.security.AccessController.doPrivileged(Native Method)
| at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
| at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
| at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:192)
| at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:404)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
| at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
| at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
| at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
| at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
| at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
| at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
| at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
| at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
| at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
| at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
| at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
| at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:440)
| at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:228)
| at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
| at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
| Caused by: java.sql.SQLException: Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; try restarting transaction"
| at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2001)
| at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
| at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
| at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
| at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1825)
| at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1667)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
| ... 66 more
| |#]
|
| [#|2008-06-11T15:25:54.718-0600|SEVERE|sun-appserver9.1|org.jbpm.svc.Services|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8181-0;_RequestID=19aa71bc-558c-4a56-8bc9-a53954446fcd;|problem closing service 'persistence'
| org.jbpm.persistence.JbpmPersistenceException: hibernate commit failed
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:219)
| at org.jbpm.svc.Services.close(Services.java:225)
| at org.jbpm.JbpmContext.close(JbpmContext.java:139)
| at processes.JBPMController.closeJbpmContext(JBPMController.java:375)
| at net.bresnan.elemer.controller.ProcessController.assignTask(ProcessController.java:193)
| 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:597)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
| at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
| at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
| at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
| at javax.faces.component.UICommand.broadcast(UICommand.java:383)
| at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
| at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
| at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| at sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:276)
| at java.security.AccessController.doPrivileged(Native Method)
| at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
| at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
| at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:192)
| at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:404)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
| at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
| at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
| at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
| at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
| at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
| at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
| at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
| at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
| at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
| at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
| at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
| at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
| at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:440)
| at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:228)
| at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
| at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
| Caused by: org.hibernate.exception.GenericJDBCException: could not update: [org.jbpm.taskmgmt.exe.TaskInstance#93]
| at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
| at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
| at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
| at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
| at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
| at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
| at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
| at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
| at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
| at org.jbpm.persistence.db.DbPersistenceService.commit(DbPersistenceService.java:256)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:214)
| ... 53 more
| Caused by: java.sql.SQLException: Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; try restarting transaction"
| at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2001)
| at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
| at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
| at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
| at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1825)
| at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1667)
| at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
| ... 66 more
|
I've highlighted in bold-face the two exceptions in particular that I am most concerned with. If anyone can shed some light on this issue, I'll be extremely thankful, since the deadline for this project is at the end of this month. Please let me know if I've misposted this in the wrong forum, or if more information is required. Thank you all very much in advance!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4157515#4157515
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4157515
16 years, 5 months