Hi Tom Sebastian,
It was caused by the fact that after you restart the application there is no listener initialized to listen to the Task Complete Event sent by Human Task Service.
When you create new process instance, it will initialize this listener when it creates the Task, so thats why things works correctly after you trigger a new process instance.
If you embed the jbpm in your application then:
you will need to re-initialize the session once your application start.
If I remember correctly, there is a discussion in this forum that discuss about this, maybe that will help you.
If you use jbpm as a service (using jbpm-console REST Services), then:
I haven't tried this myself, but Maciej Swiderski suggest to create a servletContextListener that will initialize the session once the server is started.
this is the sample code
So we need to:
1. Create a class like that, then fill in the code in contextInitialized() section to initialize the section.
If you use guvnor as process repository and have guvnor deployed in the same server as jbpm-gwt-console-server.war then maybe you need to put a delay before initializing the session
2. Package the class to a jar and put it inside jbpm-gwt-console-server.war inside the lib directory
3. Register a listener to the web.xml inside jbpm-gwt-console-server.war
Did u mean the task completed listener as below?
TaskEventKey key = new TaskEventKey(TaskCompletedEvent.class, -1);
TaskCompletedHandler eventResponseHandler = new TaskCompletedHandler(manager, client);
client.registerForEvent(key, false, eventResponseHandler);
I called this code while starting the application, still it wont continue. But in my code for every startup of application we create a new StatefulKnowledgeSession and new task client. Is this a problem?
Hi Tom Sebastian,
The new task client should not be a problem since I do that too.
Not sure about the new StatefulKnowledgeSession. Since I am using JBPM as a Service and jbpm console use single session. Can you try to persist your StatefulKnowledgeSession in database and reinitialize that StatefulKnowledgeSession on server start?
Now I reinitialize the previous StatefulKnowledgeSession after restart. Still the same problem exists(not continuing to next step)..
But i have a doubt, should we do anything while stopping the application(ie do we need to explicitly persist sessioninfo ?). Actually i kill the application and the last modification date of sessioninfo is not changing at that time. Is anything we need to code?
I got the solution.
1. While restarting application, re-registers listeners to the task client.
2. In my case starting process was like this:
ProcessInstance pi = ksession.createProcessInstance("com.sample.bpmn", null);
for such multiple command execution need to use transaction(see :http://docs.jboss.org/jbpm/v5.2/userguide/ch07.html#d0e2914)
// create the entity manager factory and register it in the environment
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
// create a new knowledge session that uses JPA to store the runtime state
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
// start the transaction
UserTransaction ut =
(UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
// perform multiple commands inside one transaction
ksession.insert( new Person( "John Doe" ) );
ksession.startProcess( "MyProcess" );
// commit the transaction
Now problem is solved . for more info see discussion at https://community.jboss.org/thread/195660
Thanks for ur help...