[rules-users] drools flow package issue

nesta.fdb nesta.fdb at 163.com
Fri Nov 20 00:25:44 EST 2009


Drools version: 5.0.1
I defined two flows, one is main flow and the other is sub flow.
These two flows have same package name, and are built and added into one knowledge base.
When I start the main flow process, the NoSuchMethod error is thrown out.

I also test with two unrelated flows, and I can't get correct result. 

So my question is that whether there is the constraint which two flows must not have same package name?

main.rf
<?xml version="1.0" encoding="UTF-8"?> 
<process xmlns="http://drools.org/drools-5.0/process"
         xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
         xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
         type="RuleFlow" name="flow" id="process_plan" package-name="sample" version="" >

  <header>
    <variables>
      <variable name="v1" >
        <type name="org.drools.process.core.datatype.impl.type.BooleanDataType" />
        <value>false</value>
      </variable>
    </variables>
  </header>

  <nodes>
    <start id="1" name="Start" x="195" y="15" width="30" height="30" />
    <split id="2" name="Split" x="185" y="70" width="40" height="40" type="2" >
      <constraints>
        <constraint toNodeId="10" toType="DROOLS_DEFAULT" name="a" priority="1" type="code" dialect="java" >return v1;</constraint>
        <constraint toNodeId="11" toType="DROOLS_DEFAULT" name="b" priority="1" type="code" dialect="java" >return !v1;</constraint>
      </constraints>
    </split>
    <join id="5" name="Join" x="185" y="260" width="40" height="40" type="2" />
    <actionNode id="7" name="test" x="155" y="320" width="100" height="80" >
        <action type="expression" dialect="java" >System.out.println("Action Test");</action>
    </actionNode>
    <end id="8" name="End" x="191" y="436" width="28" height="28" />
    <subProcess id="9" name="SubProcess" x="312" y="292" width="96" height="76" processId="com.sample.subflow" independent="false" >
    </subProcess>
    <actionNode id="10" name="a" x="75" y="151" width="80" height="40" >
        <action type="expression" dialect="java" >System.out.println("a");</action>
    </actionNode>
    <actionNode id="11" name="b" x="287" y="153" width="80" height="40" >
        <action type="expression" dialect="java" >System.out.println("b");</action>
    </actionNode>
  </nodes>

  <connections>
    <connection from="1" to="2" />
    <connection from="10" to="5" />
    <connection from="11" to="5" />
    <connection from="9" to="7" />
    <connection from="7" to="8" />
    <connection from="5" to="9" />
    <connection from="2" to="10" />
    <connection from="2" to="11" />
  </connections>

</process>

sub.rf
<?xml version="1.0" encoding="UTF-8"?> 
<process xmlns="http://drools.org/drools-5.0/process"
         xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
         xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
         type="RuleFlow" name="subflow" id="com.sample.subflow" package-name="sample" version="" >

  <header>
  </header>

  <nodes>
    <start id="1" name="Start" x="29" y="76" width="30" height="30" />
    <actionNode id="2" name="Action" x="134" y="51" width="100" height="80" >
        <action type="expression" dialect="java" >System.out.println("This is test subflow");</action>
    </actionNode>
    <end id="3" name="End" x="309" y="77" width="28" height="28" />
    <actionNode id="4" name="Action" x="240" y="210" width="100" height="80" >
        <action type="expression" dialect="java" >System.out.println("This is test 2222");</action>
    </actionNode>
  </nodes>

  <connections>
    <connection from="1" to="2" />
    <connection from="4" to="3" />
    <connection from="2" to="4" />
  </connections>

</process>

Test codes:
public class XiaYuSubflowTest {
    
    public static void main(String[] args) {
        KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        builder.add(ResourceFactory.newClassPathResource("main.rf"), ResourceType.DRF);
        builder.add(ResourceFactory.newClassPathResource("sub.rf"), ResourceType.DRF);
        if (builder.hasErrors()) {
            System.out.println(builder.getErrors());
        }
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages(builder.getKnowledgePackages());
        StatefulKnowledgeSession sks = kbase.newStatefulKnowledgeSession();        
        sks.startProcess("process_plan");    
        sks.dispose();        
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091120/a162a2fd/attachment.html 


More information about the rules-users mailing list