2 Replies Latest reply on Apr 10, 2007 12:32 PM by Jean-Francois Taillon

    Accessing file that is not in DB from deployed jBPM process

    M K Newbie


      I've got a problem accessing a file that is not deployed in the jBPM database. I want to access it in an ActionHandler of a deployed process. When test-running the jBPM process through teh jBPM API (through token.signal() etc) the file is found but when running the deployed process through the jbpm webapp, a JbpmException occurs saying:

      org.jbpm.JbpmException: couldn't get value for file 'com/sample/action/Sample.drl'

      and further down in the console:

      Caused by: org.jbpm.JbpmException: file 'com/sample/action/Sample.drl' not found in db

      Te critical piece of code from the ActionHandler-class is the following:

      package com.sample.action;
      public class FireRulesActionHandler implements ActionHandler {
      Reader reader = new InputStreamReader(FireRulesActionHandler.class.getResourceAsStream(rulefile));

      Thanks in advance.
      Best regards,

        • 1. Re: Accessing file that is not in DB from deployed jBPM proc
          M K Newbie


          it's me again. My description was a bit imprecise before. The file 'Sample.drl' should actually be deployed in the database. At least I selected the 'Sample.drl' in the Deployment tab of the eclipse plugin together with some java classes that my process or belonging drools rules need ('FireRulesActionHandler.java' and 'IntValue.java'). Then I deployed the process and the named files to the server and the "Deployment successful"-Dialog appeared.

          The problem is that when running the process not all of the files are available. The 'FireRulesActionHandler" seems to be there because it is executed just fine but the 'Sample.drl' and the 'IntValue' class seem to be unavailable. I access the 'Sample.drl' through a FileInputStream now as a workaround:

          Reader reader = new InputStreamReader(new FileInputStream("C:/Temp/Sample.drl"));
          but still the 'IntValue' class cannot be found by the JBPM webapp during execution of the process. The error stack says:

          20:28:49,176 ERROR [[FacesServlet]] Servlet.service() for servlet FacesServlet threw exception
          javax.faces.FacesException: Error calling action method of component with id taskform:transitionButton
          Caused by: org.drools.rule.InvalidRulePackage: Unable to resolve ObjectType 'IntValue'

          The 'Sample.drl' rule file, which contains the rules that are being fired by the FireRulesActionHandler, which is called during execution of the process, looks as follows:

          package com.sample.action
          #package com.sample
          import org.jbpm.context.exe.ContextInstance;
          import org.jbpm.taskmgmt.def.Task;
          import org.jbpm.taskmgmt.exe.TaskInstance;
          import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
          import org.jbpm.graph.exe.ProcessInstance;
          import org.jbpm.graph.exe.ExecutionContext;
          import com.sample.action.IntValue;
          rule "Check Number"
           ci : ContextInstance()
           IntValue (intVal : value, value > 100)
           ci.setVariable("number", "999");
           System.out.println("Changed number!");

          And as I said, when testing the whole process including firing rules and everything through the jbpm API without deploying it and using the web app then it is executing just fine...

          The files should be stored somewhere in the database when they are being deployed right? But where exactly are they supposed to go?
          Does anybody know why this is not working?
          Many thanks in advance!

          • 2. Re: Accessing file that is not in DB from deployed jBPM proc
            Jean-Francois Taillon Newbie

            I have the exact same problem as well.

            Option 1 (raises not found in database error)
            Reader reader = new InputStreamReader(Main.class.getResourceAsStream("AmountRule.drl"));

            Option 2 (raises classloader issues, imported classes in drl file are not found)
            Reader reader = new InputStreamReader(new FileInputStream("D:/dev/iai/src/rules/AmountRule.drl"));

            This is a very important issue as we are not able to mix the jBPM engine with the Rule Engine...

            The project I am involved in requires both.

            By the way, just executing the Rule file (DRL) from a main class works perfectly.

            I am using the jbpm-starterskit-3.1.3.

            Help needed!!!