[jboss-user] [JBoss jBPM] - Help- Database empties on restarting & making call to workfl

gnaik do-not-reply at jboss.com
Thu Jun 11 11:06:51 EDT 2009


Hi,
    I am using jbpm 3.2.6.sp1 and facing a very big problem, when i restart the jbpm workflow engine and make any calls to engine the database is cleared. Ithink i am going wrong somewhere while starting and fetching the process Instance. Plz Help.

The sequence of tasks that i follow :-
I have created an RMI interface to interact the engine.

1. I start the workflow engine:-
main(){
  |        jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml");
  |        deploy("processdefinition.xml");
  | }
  | 
  | 
  | public String deploy(String resourceName) throws RemoteException {
  |         System.out.println("-------Inside Deploy--------");
  |         ProcessDefinition processDefinition = null;
  |         String processId = "";
  |         JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  |         try {
  |             processDefinition = ProcessDefinition.parseXmlResource(resourceName);
  |             jbpmContext.deployProcessDefinition(processDefinition);
  |         } finally {
  |             jbpmContext.close();
  |         }
  |         processId = String.valueOf(processDefinition.getId());
  |         System.out.println("....Process Definition " + processDefinition.getName() + " Deployed....");
  |         System.out.println("-------Out of Deploy--------");
  |         return processId;
  |     }

2. Through RMI interface i give call to create a process Instance of deployed processdefinition.

public String StartExecution(String processDefinitionKey, String inExecutionKey, String actorId, Map<String, Object> localParameters, Map<String, Object> parameters) throws RemoteException {
  |         JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  |         String executionKey = "";
  |         try {
  |             GraphSession graphSession = jbpmContext.getGraphSession();
  |             ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition(processDefinitionKey);
  |             if (processDefinition != null) {
  |                 ProcessInstance processInstance = processDefinition.createProcessInstance();
  |                 if (processInstance != null) {
  |                     if (inExecutionKey == null || inExecutionKey.equalsIgnoreCase("")) {
  |                         executionKey = processDefinitionKey + ":" + processInstance.getId();
  |                     } else {
  |                         executionKey = inExecutionKey;
  |                     }
  |                     processInstance.setKey(executionKey);
  |                     System.out.println("Execution Key : " + executionKey);
  |                     ContextInstance contextInstance = processInstance.getContextInstance();
  |                     if (parameters != null) {
  |                         contextInstance.setVariables(parameters);
  |                     }
  |                     if (localParameters != null) {
  |                         contextInstance.setTransientVariables(localParameters);
  |                     }
  |                     Token token = processInstance.getRootToken();
  |                     System.out.println("Root Node : " + token.getNode().getName());
  |                     if (actorId != null) {
  |                         if (LdapHelper.isValidUser(actorId)) {
  |                             contextInstance.setVariable(INITIATOR, actorId);
  |                             token.signal();
  |                         } else {
  |                             System.out.println(actorId + " is not present in LDAP");
  |                             throw new ResourceNotFoundException(actorId + " is not present in LDAP");
  |                         }
  |                     } else {
  |                         token.signal();
  |                     }
  |                     jbpmContext.save(processInstance);
  |                 } else {
  |                     System.out.println("Process Instance not found");
  |                 }
  |             } else {
  |                 System.out.println("Process defn not found");
  |             }
  |         } finally {
  |             jbpmContext.close();
  |         }
  |         System.out.println("-------Out of Create ProcessInstance--------");
  |         jbpmConfiguration.startJobExecutor();
  |         return executionKey;
  |     }

3. Stop the workflow engine by stopping the RMI server.

4. Start the workflow engine again but with deploy.

main(){
  |        jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml");
  | }

5. At this point the database has values present.
 
6. Now i try to fetch the current state of the processInstance started, But it fails saying process definition not found.

public String VWFGetCurrentNodeName(String processDefinitionKey, String executionKey) throws RemoteException {
  |         JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  |         String currentNodeName = "";
  |         try {
  |             GraphSession graphSession = jbpmContext.getGraphSession();
  | //CLEARS THE DATABASE ON EXECUTING THIS LINE.
  |             ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition(processDefinitionKey);
  |             if (processDefinition != null) {
  |                 ProcessInstance processInstance = jbpmContext.getProcessInstance(processDefinition, executionKey);
  |                 if (processInstance != null) {
  |                     Token token = processInstance.getRootToken();
  |                     currentNodeName = token.getNode().getName();
  |                 } else {
  |                     System.out.println("Process Instance not found");
  |                 }
  |             } else {
  |                 System.out.println("Process defn not found");
  |             }
  |         } finally {
  |             jbpmContext.close();
  |         }
  |         System.out.println("Current Node : " + currentNodeName);
  |         return currentNodeName;
  |     }


Plz Guide me..

Regards,
Gautam.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4237053#4237053

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4237053



More information about the jboss-user mailing list