4 Replies Latest reply on Mar 22, 2011 4:04 AM by whizkid.samrat

    JBPM exception : no process definition with key

    whizkid.samrat

      Hi I am new to jBpm  , though I have run a couple of examples and i am comfortable with the idea.

       

      I am trying to build a spring web application with jBpm 4.4 and I have defined my process defintion jpdl files. The problem is :

       

      I have made a Spring bean in the application Context as :

       

      <bean id="jbpmRepositoryUtil" class="com.canon.common.util.JbpmRepositoryUtil">

          <constructor-arg>

              <value>jpdl/LeaveApply.jpdl.xml</value>

          </constructor-arg>

          <constructor-arg>

              <value>jpdl/LeaveDB_bal_Status.jpdl.xml</value>

          </constructor-arg>

          <constructor-arg>

               <value>jpdl/ApproverFlow.jpdl.xml</value>

          </constructor-arg>

          <constructor-arg>

               <ref bean ="repositoryService"/>

          </constructor-arg>

      </bean>

       

       

      This bean deploys three Jpdl files at the server Startup (jboss 4.2) . Like:

      public JbpmRepositoryUtil (String mainJpdlPath,String subProcessPath,String approverPath ,RepositoryService repositoryService){

              mainFlowId = repositoryService.createDeployment().addResourceFromClasspath(mainJpdlPath).deploy();

              dbSubProcessId = repositoryService.createDeployment().addResourceFromClasspath(approverPath).deploy();

              approverFlowId = repositoryService.createDeployment().addResourceFromClasspath(subProcessPath).deploy();

          }

       

       

       

      I have run the server in debug mode an confirmed that the method is being hit.

       

      But when I try to start a process instance in my service class like :

       

      ProcessInstance processInstance = executionService.startProcessInstanceByKey("LeaveApply",variables);

       

      I get the following error :

       

      org.jbpm.api.JbpmException: no process definition with key 'LeaveApply'

          at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:58)

          at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:36)

          at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)

          at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45)

      .....

       

       

      Naming isnt an issue because if i copy the createDeployment method to the service class just before trying to create a PI it works just fine ..  but according to my understanding I should be deploying the jpdl just once and create ProcessInstance as and when needed. So copying to the service class is a bad idea !

       

      Adding to the previous :

      I am using the same sessionFactory for both jbpm and my application .

       

      Please find attached my jBpm-Context.xml and jbpm-cfg.xml

       

      HELP !

        • 1. JBPM exception : no process definition with key
          jdh

          It looks like you are deploying a JPDL file.  When you define the process you need to give it a key.  Can you verify that the Process starts something like this:

           

          <process key="LeaveApply" name="LeaveApplyProc" version="1" xmlns="http://jbpm.org/4.4/jpdl">

            ...

          </process>

           

          That's all I can think of that might cause that error.

          Jim

          • 2. JBPM exception : no process definition with key
            whizkid.samrat

            Hi Jim,

             

            That isnt an issue. Though not as verbose a yours but my defintition still says.

             

            <process name="LeaveApply" xmlns="http://jbpm.org/4.4/jpdl">

            ...

            </process>

             

            if I deploy the jpdl just before I try to make a Process Instance everthing is fine and gala.  But when I try to deploy the resources through a spring bean at the server startup and then try to make a process instance afterwords everthing goes ka-boom !

             

            secondly .. the api keeps mentioning something called "ProcessDefinitionID" by which I can start a process instance aswell .

            ProcessInstancestartProcessInstanceById(java.lang.String processDefinitionId)

             

            What exactly is a processDefinitionID and how do I get it ? ideas?

             

            Thanks !

            • 3. JBPM exception : no process definition with key
              jdh

              Sorry to take so long to respond.  I am not sure what your processDefinitionId would be.  I assume it's a unique id representing your process.  Instead of using the startProcessInstanceById, I have opted to use startProcessInstanceByKey.  This key is the business Id I have applied to the objects passed in and out of this process.  could you try this option and see if you get better results?

               

              Jim

              • 4. JBPM exception : no process definition with key
                whizkid.samrat

                @Jim .. i worked out the problem . Instead of deployoing the jpdl at startup I wrote a singleton to take care of it when required. That is working.

                 

                Thanks

                Samrat