[JBoss jBPM] - Token lock issue
by firetruck
I have an issue with locking a Token.
When an action starts to execute inside a Node, I lock the token with the method lock() from the Token object. That's to avoid the use of it, while the action is executing.
Then, in another part of my code, i try to verify if the token is locked. I do this:
Token token= jbpmContext.loadToken(processInstance.getRootToken().getId());
| if(token.isLocked()){
| ...
| }
|
My problem is that when I load the token to check if it is locked, I don't get the same object that I locked in the Node. Instead, the token seems to be reloaded from database, and when it happens, the value of isLocked is lost, because it is a transient attribute.
How should I do to load the exactly same object that I had previously locked in the Node?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4194295#4194295
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4194295
17 years, 4 months
[JBoss jBPM] - Re: how to implement co-sign a task by several person?
by aspider
Based on codes mentioned above, i have been confused by this problem for several days, who can tell me how to write 'task-end' action.
Test the process, i always get this error:
| org.jbpm.JbpmException: this token is locked by token[0]
| at org.jbpm.graph.exe.Token.signal(Token.java:182)
| at org.jbpm.graph.exe.Token.signal(Token.java:140)
| at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:479)
| at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:393)
| at com.sample.action.CosignTaskEndHandler.execute(CosignTaskEndHandler.java:37)
| at org.jbpm.graph.def.Action.execute(Action.java:122)
| at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:259)
| at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:215)
| at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:185)
| at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:198)
| at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:169)
| at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:452)
| at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:393)
| at com.sample.action.CosignTaskEndHandler.execute(CosignTaskEndHandler.java:37)
| at org.jbpm.graph.def.Action.execute(Action.java:122)
| at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:259)
| at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:215)
| at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:185)
| at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:198)
| at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:169)
| at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:452)
| at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:393)
| at com.sample.SimpleProcessTest.testSimpleProcess(SimpleProcessTest.java:59)
| 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 junit.framework.TestCase.runTest(TestCase.java:154)
| at junit.framework.TestCase.runBare(TestCase.java:127)
| at junit.framework.TestResult$1.protect(TestResult.java:106)
| at junit.framework.TestResult.runProtected(TestResult.java:124)
| at junit.framework.TestResult.run(TestResult.java:109)
| at junit.framework.TestCase.run(TestCase.java:118)
| at junit.framework.TestSuite.runTest(TestSuite.java:208)
| at junit.framework.TestSuite.run(TestSuite.java:203)
| at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
| at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
| at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4194261#4194261
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4194261
17 years, 4 months
[JBoss jBPM] - help ,error while use timer
by start bomb
this processdefinition:
| <?xml version="1.0" encoding="UTF-8"?>
| <process-definition xmlns="" name="tt">
| <start-state name="start-state1">
| <transition to="node4"></transition>
| </start-state>
| <state name="node4">
| <timer duedate="10 second" name="aa" transition="timeout">
| <script>
| System.out.println("----------------->time out");
| </script>
| </timer>
| <transition to="fork1" name="timeout"></transition>
| </state>
| <fork name="fork1">
| <transition to="join1"></transition>
| </fork>
| <join name="join1">
| <transition to="end-state1"></transition>
| </join>
| <end-state name="end-state1"></end-state>
| </process-definition>
|
while the timer 'aa' arrives the duedate,there will be a exception:
2008-12-04 14:53:05,737 [] ERROR def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.job.Timer#43]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2523)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2697)
at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:74)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146)
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:260)
at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:218)
at org.jbpm.svc.Services.close(Services.java:223)
at org.jbpm.JbpmContext.close(JbpmContext.java:139)
at org.jbpm.job.executor.JobExecutorThread.executeJob(JobExecutorThread.java:193)
at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:64)
but if the transition of the timer dosen't point to a fork,for example a state ,there won't have such exception. can angbody help me?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4194216#4194216
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4194216
17 years, 4 months
[JBoss jBPM] - Re: how to implement co-sign a task by several person?
by aspider
sorry, the example as below.
to make the code clear for you , i post it again.
please help me to have a look, whats the problem.
especially in CosignTaskEndHandler.
Thanks a lot!
| <?xml version="1.0" encoding="UTF-8"?>
| <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
| <start-state name="start">
| <transition to="create">
| </transition>
| </start-state>
| <task-node name="create">
| <task name="createTask">
| <controller>
| <variable name="approvedName"></variable>
| </controller>
| <assignment class="com.sample.assignment.DealAssignment">
| </assignment>
| </task>
| <transition to="message"></transition>
| </task-node>
|
| <state name="message">
| <transition to="approval"></transition>
| </state>
|
| <task-node name="approval" create-tasks="false" signal="last-wait">
| <event type="node-enter">
| <action name="approvalAction" class="com.sample.action.CosignActionHandler">
| </action>
| </event>
| <event type="task-end">
| <action
| class="com.sample.action.CosignTaskEndHandler">
| </action>
| </event>
| <task name="approvalTask">
| </task>
| <transition to="write"></transition>
| </task-node>
|
| <node name="write">
| <action name="action" class="com.sample.action.MessageActionHandler">
| <message>About to finish!</message>
| </action>
| <transition to="end"></transition>
| </node>
|
|
| <end-state name="end"></end-state>
| </process-definition>
|
CosignActionHandler.java
| public class CosignActionHandler implements ActionHandler {
|
| private static final long serialVersionUID = 1L;
| private static final Log log = LogFactory.getLog(CosignActionHandler.class);
|
| public void execute(ExecutionContext context) throws Exception {
|
| List approveNameList = (List)context.getVariable("approvedName");
| log.info(approveNameList.size());
| Token token = context.getToken();
| TaskMgmtInstance tmi = context.getTaskMgmtInstance();
| TaskNode taskNode = (TaskNode) context.getNode();
| Task task = taskNode.getTask("approvalTask");
| for(int i=0; i<approveNameList.size(); i++){
| String appName = (String)approveNameList.get(i);
| tmi.createTaskInstance(task, token).setActorId(appName);
| log.info("appName:" + appName +" task created");
| }
|
| }
|
| }
|
CosignTaskEndHandler.java
| public class CosignTaskEndHandler implements ActionHandler {
|
| private static final long serialVersionUID = 1L;
| private static final Log log = LogFactory.getLog(CosignTaskEndHandler.class);
|
| public void execute(ExecutionContext context) throws Exception {
| boolean isDisapprove = true;
| log.info("isDisapprove:"+isDisapprove);
| if (isDisapprove) {
| TaskMgmtInstance tmi = context.getTaskMgmtInstance();
| TaskInstance ti = context.getTaskInstance();
| final String actorId = ti.getActorId();
| Collection c = tmi.getSignallingTasks(context);
|
| for (Iterator it = c.iterator(); it.hasNext();) {
| TaskInstance task = (TaskInstance) it.next();
| if (!(actorId.equals(task.getActorId())) && (!task.hasEnded())) {
| task.end("write");
| }
| }
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4194193#4194193
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4194193
17 years, 4 months
[JBoss jBPM] - Re: how to implement co-sign a task by several person?
by aspider
I have made a example.
Process Definition like this, i want to co-sign in 'approval' task node. And define 2 action in it.
The dynamic task creation is ok, but sth wrong with CosignTaskEndHandler
could you give advice?
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
<start-state name="start">
</start-state>
<task-node name="create">
</task-node>
<task-node name="approval" create-tasks="false" signal="last-wait">
</task-node>
About to finish!
<end-state name="end"></end-state>
</process-definition>
CosignActionHandler.java
public class CosignActionHandler implements ActionHandler {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(CosignActionHandler.class);
public void execute(ExecutionContext context) throws Exception {
List approveNameList = (List)context.getVariable("approvedName");
log.info(approveNameList.size());
Token token = context.getToken();
TaskMgmtInstance tmi = context.getTaskMgmtInstance();
TaskNode taskNode = (TaskNode) context.getNode();
Task task = taskNode.getTask("approvalTask");
for(int i=0; i<approveNameList.size(); i++){
String appName = (String)approveNameList.get(i);
tmi.createTaskInstance(task, token).setActorId(appName);
log.info("appName:" + appName +" task created");
}
}
}
CosignTaskEndHandler.java
public class CosignTaskEndHandler implements ActionHandler {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(CosignTaskEndHandler.class);
public void execute(ExecutionContext context) throws Exception {
boolean isDisapprove = true;
log.info("isDisapprove:"+isDisapprove);
if (isDisapprove) {
TaskMgmtInstance tmi = context.getTaskMgmtInstance();
TaskInstance ti = context.getTaskInstance();
final String actorId = ti.getActorId();
Collection c = tmi.getSignallingTasks(context);
for (Iterator it = c.iterator(); it.hasNext();) {
TaskInstance task = (TaskInstance) it.next();
if (!(actorId.equals(task.getActorId())) && (!task.hasEnded())) {
task.end("write");
}
}
}
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4194192#4194192
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4194192
17 years, 4 months