2 Replies Latest reply on Nov 24, 2014 3:31 AM by Santhosh Bhat

    Resuming a process, which got terminated due to JVM crash / server crash

    Santhosh Bhat Newbie



      I am trying to work on a unit-test (before I put this into application), which will resume and re-run a process, from the state which it last executed, when it got aborted due to JVM crash/server crash. I went through the example given in the user-guide, http://docs.jboss.org/jbpm/v6.0/userguide/jBPMPersistence.html


      Also, I tried to dig up, old threads posted on the forum on the same issue.


      1. https://developer.jboss.org/message/720541#720541

      2. https://developer.jboss.org/message/797952#797952

      3. https://developer.jboss.org/message/745064#745064


      All of them, did not give me an answer I was looking for.


      How am I creating the session and running the process?

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.services.task");

         RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf)

        .userGroupCallback(new JBossUserGroupCallbackImpl(getUserGroupProperties()))

        .addAsset(ResourceFactory.newUrlResource(workflowFile), ResourceType.BPMN2)


          // "workflowFile" refers to the absolute URL to the .bpmn2 file in the system. Eg: file:///c:/test.bpmn2


        RuntimeManager runtimeManager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment);

        RuntimeEngine runtime = runtimeManager.getRuntimeEngine(EmptyContext.get());

        KieSession ksession = runtime.getKieSession();



      After this step, I will abort the program. I check the DB, and I see that the new session information and process information has been persisted. Now I run another program to resume the process from where it left of, and it looks like this



      EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.services.task");
      KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
      Environment env = KnowledgeBaseFactory.newEnvironment();


        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
      StatefulKnowledgeSession ksession =  JPAKnowledgeService.loadStatefulKnowledgeSession(4, kbase, null, env);


      I don't see that the process is being resumed when I load the KieSession from the DB. Should any API be explicitly invoked for this? Please help me on this.