Hi Everyone,<br><br>I'm having a problem adding a rule to a custom package. I have a drl file in the com.sample package. I read in that drl file and everything is fine. I then wish to add another rule to the KnowledgeBase as a String. I'm using the following code for this (where kbase is the existing KnowledgeBase with the preloaded rules):<br>
<br><span style="color: rgb(51, 51, 255);"> KnowledgeBuilder kbuilder2 = KnowledgeBuilderFactory.newKnowledgeBuilder(kbase);</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);"> </span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> String rule = "rule \"GeneralClause-2\" " +</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);"> "when " +</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> "ObligationComplianceEvent(term == \"term2\", obligation == \"obligation1\", level == 2) " +</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> "then " +</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);"> "contract.setState(\"Hello\");" +</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> "end";</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);"> </span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> Resource ruleResource = ResourceFactory.newReaderResource((Reader) new StringReader(rule));</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);"> kbuilder2.add(ruleResource, ResourceType.DRL); </span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);"> kbase.addKnowledgePackages(kbuilder2.getKnowledgePackages());</span><br><br>
It appears to fails when I call fireUntilHalt() on my session with the following exception:<br><br><span style="color: rgb(51, 102, 255);">Exception in thread "Thread-1" java.lang.NoClassDefFoundError: defaultpkg/Rule_GeneralClause_2_0</span><br>
<br>It appears the new rule was added to the default package, and it relies on events defined in com.sample so I'm assuming this is the problem. My question is how can I add this rule to com.sample along with the previously loaded rules? I'm very desperate here, any help is greatly appreciated!<br>
<br>Cheers,<br><br>Justin<br>