Thank you Mark,
I added the error checking code as advised :
//read in the source
final Reader source = new InputStreamReader( HelloWorldExample.class.getResourceAsStream( "HelloWorld.drl" ) );
final PackageBuilder builder = new PackageBuilder();
//this will parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for normal DRL.
builder.addPackageFromDrl( source );
//get the compiled package (which is serializable)
final Package pkg = builder.getPackage();
PackageBuilderErrors pbe = builder.getErrors();
DroolsError[] de = pbe.getErrors();
for (int i = 0; i < de.length; i++) {
System.out.println("ERROR["+i+"]:" + de[i]);
}
System.out.println("pkg.getErrorSummary() : " + pkg.getErrorSummary());
//add the package to a rulebase (deploy the rule package).
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
And here is what I got:
pkg.getErrorSummary() : null
Exception in thread "main" java.lang.IllegalArgumentException: The rule called Hello World is not valid. Check for compile errors reported.
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:363)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:263)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:293)
at org.drools.examples.HelloWorldExample.readRule(HelloWorldExample.java:72)
at org.drools.examples.HelloWorldExample.main(HelloWorldExample.java:21)
So basically – no errors…? Or … am I showing errors correctly?
Also could you please specify what do you mean under “java is invalid”. You mean JDK level? I am using JANINO 2.5.6 compiler in JVM 1.4 .. is this correct configuration?
Thanks again!
-Sergey
From: rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Mark Proctor
Sent: Friday, June 08, 2007 10:17
AM
To: Rules Users List
Subject: Re: [rules-users] problem
in rules 4.0.0.11754MR2
The consequence will be null if the java you used is
invalid. When you create the Package check the errors before adding it to the
rule base as you can get a lot more info. In fact thats good "best
practice" always verify that the package errors are emtpy before
attempting to use the package.
Mark
Manukyan, Sergey wrote:
Hi,
I am using JBoss Rules 4.0.0.11754MR2 in an RAD 7.0 (Eclipse 3.2) environment.
Cannot make it work, even examples…
Here is a message produces on all rules: The rule called <here goes rule name> is not valid. Check for compile errors reported.
Here is a full stack trace:
Exception in thread "main" java.lang.IllegalArgumentException: The rule called Hello World is not valid. Check for compile errors reported.
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:363)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:263)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:293)
at org.drools.examples.HelloWorldExample.readRule(HelloWorldExample.java:72)
at org.drools.examples.HelloWorldExample.main(HelloWorldExample.java:21)
After digging it further I found that in Rule class method isValid is being called defiend as followes:
public boolean isValid() {
if ( this.consequence == null || !isSemanticallyValid() ) {
return false;
}
return true;
}
The debugger shows that this.consequence is null always! So rules are always not valid.
Anyone saw this problem? Any idea how to resolve it?
Thanks a lot!
-Sergey
********************** |
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users