0 Replies Latest reply on Dec 18, 2009 2:44 AM by Deepak Sharma

    Problem in simple helloworld application

    Deepak Sharma Newbie

      Hello All,

       

      I am a newbie in JBPM. I have been given task to create workflows.

       

      I have already installed JBPM4.0, and JBOSS AS 5.0 and its running successfully.

      I have also been able to run the examples provided in JBPM 4.0

       

      I have referred the following document as a reference:

      http://www.jorambarrez.be/blog/2009/07/01/jbpm4-hello-world/

       

      So, starting from the basic example "helloworld" using above configurations, i am unable to create it successfully

       

      I have created "java project"

      folders.bmp

      Following are the files of my application:

       

      helloWorld.jpdl.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process name="helloWorld" xmlns="http://jbpm.org/4.0/jpdl">
         <start g="17,64,48,48" name="start">
            <transition to="printHelloWorld"/>
         </start>
         
         <java class="com.tifr.jbpm4.helloworld.Printer" g="221,61,190,52" method="printHelloWorld" name="printHelloWorld">
            <transition to="theEnd"/>
         </java>
         
           <end g="523,60,48,48" name="theEnd"/>
      </process>
      

       

      Printer.java

       

      package com.tifr.jbpm4.helloworld;
      
      public class Printer {
           public void printHelloWorld()
           {
                System.out.println("<---------------->");
                System.out.println("Hello World");
                System.out.println("<---------------->");          
           }
      }
      

       

      helloWorldTest.java

      package com.tifr.jbpm4.helloworld;
      
      import org.jbpm.api.Configuration;
      import org.jbpm.api.ExecutionService;
      import org.jbpm.api.ProcessDefinition;
      import org.jbpm.api.ProcessEngine;
      import org.jbpm.api.ProcessInstance;
      import org.jbpm.api.RepositoryService;
      
      public class helloWorldTest {
           
           private static ProcessEngine processEngine;      
           private static RepositoryService repositoryService;
           private static ExecutionService executionService;
            
           static {
                           
            processEngine = new Configuration().buildProcessEngine();//.setResource("jbpm.cfg.xml").buildProcessEngine();
            System.out.println("processEngine: " + processEngine);     
            
            repositoryService = processEngine.getRepositoryService();//.get(RepositoryService.class);
            System.out.println("repositoryService: " + repositoryService);
            
            executionService = processEngine.getExecutionService();
            System.out.println("executionService: " + executionService);
            
           }
       
           
           public static void main(String[] args) {
                
                try
                {
                
                //create new deployment object and ask it to deploy your flow
                 String deploymentId = repositoryService.createDeployment()
                                          .addResourceFromClasspath("com/tifr/jbpm4/helloworld/helloWorld.jpdl.xml")
                                          .deploy();
                 
                 //now we query the process definition
                 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).uniqueResult();
                 
                 //start the process instance with the Id of the process definition
                 ProcessInstance processInstance = executionService.startProcessInstanceById(processDefinition.getId());
      
                }
                catch(Exception e)
                {     
                     e.printStackTrace();
                }
           }
                 
      }
      

       

      jbpm.cfg.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <jbpm-configuraton>
           <import resources="jbpm.default.cfg.xml" ></import>
           <import resources="jbpm.tx.hibernate.cfg.xml" ></import>
           <import resources="jbpm.jpdl.cfg.xml" ></import>
           <import resource="jbpm.identity.cfg.xml" />
           
           <!-- Job executor is excluded for running the example test cases. -->
            <!-- To enable timers and messages in production use, this should be included. -->
            <!--
            <import resource="jbpm.jobexecutor.cfg.xml" />
            -->
                
      </jbpm-configuraton>
      

       

      jbpm.hibernate.cfg.xml

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      
      <hibernate-configuration>
      <session-factory>
      
      <property name="hibernate.dialect">org.hibernate.dialect.oracle10gdialect</property>
      <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
      <property name="hibernate.connection.url">jdbc:oracle:thin:@158.144.71.242:1521:dbatest</property>
      <property name="hibernate.connection.username">jbpm</property>
      <property name="hibernate.connection.password">jbpm</property>
      
      <property name="hibernate.format_sql">true</property>
      <property name="hibernate.hbm2ddl.auto">create-drop</property>
      
      <mapping resource="jbpm.repository.hbm.xml" />
      <mapping resource="jbpm.execution.hbm.xml" />
      <mapping resource="jbpm.history.hbm.xml" />
      <mapping resource="jbpm.task.hbm.xml" />
      <mapping resource="jbpm.identity.hbm.xml" />
      
      </session-factory>
      </hibernate-configuration>
      

       

      But when I run the helloWorldTest.java, it gives the following exception:

       

      processEngine: org.jbpm.pvm.internal.cfg.JbpmConfiguration@fe64b9
      repositoryService: null
      executionService: null
      java.lang.NullPointerException
           at com.tifr.jbpm4.helloworld.helloWorldTest.main(helloWorldTest.java:36)
      

       

      Could any one please help me out in running this simple application.

       

      Thanks in advance.

       

      Best Regards,

      Deepak Sharma