Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-168

jbpm-drools integration

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Major
    • None
    • None
    • None

    Description

      i am integrating jbpm process with drools. In my case during a transition from one process to another i have added an action which performs following :
      package com.sample.action;

      import java.io.InputStreamReader;
      import java.io.Reader;

      import org.apache.log4j.Logger;
      import org.drools.RuleBase;
      import org.drools.RuleBaseConfiguration;
      import org.drools.RuleBaseFactory;
      import org.drools.WorkingMemory;
      import org.drools.compiler.PackageBuilder;
      import org.drools.compiler.PackageBuilderConfiguration;
      import org.drools.rule.Package;
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;

      public class TestDroolActionHandler implements ActionHandler {

      /**

      • */
        private static final long serialVersionUID = 1L;
        static Logger logger = Logger.getLogger(TestDroolActionHandler.class);

      @Override
      public void execute(ExecutionContext executionContext) throws Exception {
      // TODO Auto-generated method stub
      try

      { RuleBase ruleBase = readRule(); WorkingMemory workingMemory = ruleBase.newStatefulSession(); Message message = new Message(); message.setMessage( "Hello World" ); message.setStatus( Message.HELLO ); workingMemory.insert( message ); workingMemory.fireAllRules(); }

      catch (Throwable t)

      { t.printStackTrace(); }

      }
      private RuleBase readRule() throws Exception

      { Reader source = new InputStreamReader( TestDroolActionHandler.class.getResourceAsStream( "/Sample.drl" ) ); //Use package builder to build up a rule package. ClassLoader classLoader = this.getClass().getClassLoader(); PackageBuilderConfiguration configuration = new PackageBuilderConfiguration(); configuration.setClassLoader(classLoader); PackageBuilder builder = new PackageBuilder(configuration); //this wil parse and compile in one step builder.addPackageFromDrl( source ); //get the compiled package (which is serializable) Package pkg = builder.getPackage(); //add the package to a rulebase (deploy the rule package). RuleBaseConfiguration ruleBaseConfiguration = new RuleBaseConfiguration(); ruleBaseConfiguration.setClassLoader(classLoader); RuleBase ruleBase = RuleBaseFactory.newRuleBase(ruleBaseConfiguration); ruleBase.addPackage( pkg ); return ruleBase; }

      public static class Message {
      public static final int HELLO = 0;
      public static final int GOODBYE = 1;

      private String message;

      private int status;

      public String getMessage()

      { return this.message; }

      public void setMessage(String message)

      { this.message = message; }

      public int getStatus()

      { return this.status; }

      public void setStatus( int status )

      { this.status = status; }

      }

      }

      this code reads .drl file:
      package com.sample.action

      import com.sample.action.TestDroolActionHandler.Message;

      rule "Hello World"
      when
      m : Message( status == Message.HELLO, message : message )
      then
      System.out.println( message );
      m.setMessage( "Goodbye cruel world" );
      m.setStatus( Message.GOODBYE );
      update( m );
      end

      rule "GoodBye"
      no-loop true
      when
      m : Message( status == Message.GOODBYE, message : message )
      then
      System.out.println( message );
      m.setMessage( message );

      end

      i get the following error:
      19:05:02,206 ERROR [STDERR] org.drools.rule.InvalidRulePackage: Unable to resolve ObjectType 'Message' : [Rule name=Hello World, agendaGroup=MAIN, salience=0, no-loop=false]
      Unable to resolve ObjectType 'Message' : [Rule name=GoodBye, agendaGroup=MAIN, salience=0, no-loop=true]
      com.sample.action.TestDroolActionHandler.MessageRule Compilation error : [Rule name=GoodBye, agendaGroup=MAIN, salience=0, no-loop=true]
      com/sample/action/Rule_GoodBye_0.java (2:35) : The import com.sample.action.TestDroolActionHandler.Message cannot be resolved
      com/sample/action/Rule_GoodBye_0.java (7:294) : message cannot be resolved
      com/sample/action/Rule_GoodBye_0.java (8:309) : m cannot be resolved
      com/sample/action/Rule_GoodBye_0.java (8:323) : message cannot be resolved
      Rule Compilation error : [Rule name=Hello World, agendaGroup=MAIN, salience=0, no-loop=false]
      com/sample/action/Rule_Hello_World_0.java (1:0) : The type com.sample.action.TestDroolActionHandler$Message cannot be resolved. It is indirectly referenced from required .class files
      com/sample/action/Rule_Hello_World_0.java (2:35) : The import com.sample.action.TestDroolActionHandler.Message cannot be resolved
      com/sample/action/Rule_Hello_World_0.java (7:298) : message cannot be resolved
      com/sample/action/Rule_Hello_World_0.java (8:313) : m cannot be resolved
      com/sample/action/Rule_Hello_World_0.java (9:355) : m cannot be resolved
      com/sample/action/Rule_Hello_World_0.java (9:368) : Message.GOODBYE cannot be resolved to a type
      com/sample/action/Rule_Hello_World_0.java (10:405) : m cannot be resolved
      19:05:02,206 ERROR [STDERR] at org.drools.rule.Package.checkValidity(Package.java:424)
      19:05:02,206 ERROR [STDERR] at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:364)
      19:05:02,206 ERROR [STDERR] at com.sample.action.TestDroolActionHandler.readRule(TestDroolActionHandler.java:79)
      19:05:02,206 ERROR [STDERR] at com.sample.action.TestDroolActionHandler.execute(TestDroolActionHandler.java:32)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.Action.execute(Action.java:122)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:264)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.Transition.take(Transition.java:138)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.Node.leave(Node.java:394)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.node.StartState.leave(StartState.java:70)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated>)
      19:05:02,206 ERROR [STDERR] at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
      19:05:02,206 ERROR [STDERR] at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:163)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$3ed7f255.leave(<generated>)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.exe.Token.signal(Token.java:195)
      19:05:02,206 ERROR [STDERR] at org.jbpm.graph.exe.Token.signal(Token.java:158)
      19:05:02,206 ERROR [STDERR] at org.jbpm.jsf.core.action.SignalActionListener.handleAction(SignalActionListener.java:56)
      19:05:02,206 ERROR [STDERR] at org.jbpm.jsf.core.impl.JbpmActionListenerWrapper.processAction(JbpmActionListenerWrapper.java:82)
      19:05:02,206 ERROR [STDERR] at javax.faces.event.ActionEvent.processListener(ActionEvent.java:77)
      19:05:02,206 ERROR [STDERR] at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:758)
      19:05:02,206 ERROR [STDERR] at javax.faces.component.UICommand.broadcast(UICommand.java:368)
      19:05:02,206 ERROR [STDERR] at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:448)
      19:05:02,206 ERROR [STDERR] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
      19:05:02,206 ERROR [STDERR] at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
      19:05:02,206 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
      19:05:02,206 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      19:05:02,206 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      19:05:02,206 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      19:05:02,206 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
      19:05:02,206 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      19:05:02,206 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      19:05:02,206 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      19:05:02,206 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      19:05:02,206 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      19:05:02,206 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      19:05:02,206 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)

      Any help will be appreciated...

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            sangeeth1989 sangeetharaman c (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: