Missing package name for rule package.
by Ronald R. DiFrango
I am getting the following exception all of a sudden:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.circuitcity.rtvcrms.test.MainBasedTester.testRules(
MainBasedTester.java:31)
at com.circuitcity.rtvcrms.test.MainBasedTester.main(
MainBasedTester.java:23)
Caused by: java.lang.RuntimeException: Failure loading the Rules
at com.circuitcity.rtvcrms.rules.RtvDecisionEngine.<clinit>(
RtvDecisionEngine.java:47)
... 2 more
Caused by: org.drools.compiler.PackageBuilder$MissingPackageNameException:Missing
package name for rule package.
at org.drools.compiler.PackageBuilder.validatePackageName(
PackageBuilder.java:278)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java
:214)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(
PackageBuilder.java:147)
at com.circuitcity.rtvcrms.rules.RtvDecisionEngine.<clinit>(
RtvDecisionEngine.java:40)
... 2 more
Here are my DRL files:
created on: Dec 7, 2006
package com.circuitcity.rtvcrms.rules
#list any import classes here.
import java.math.BigDecimal;
import java.math.BigInteger;
import com.circuitcity.rtvcrms.bw.Constants;
import com.circuitcity.rtvcrms.bw.DocumentTypes;
import com.circuitcity.rtvcrms.bw.StatusConstants;
import com.circuitcity.rtvcrms.Adjustment;
import com.circuitcity.rtvcrms.DetailLine;
import com.circuitcity.rtvcrms.EffectivePrice;
import com.circuitcity.rtvcrms.RepaymentCode;
import com.circuitcity.rtvcrms.MatchingOutput;
#declare any global variables here
global java.util.List matchedList;
rule "CM Qty EQ RTV Qty"
salience 10
when
cmDetailLine : DetailLine(cmNumber != null, lineNumber != null,
status != StatusConstants.MATCHED, cmRtvNumber : cmRtvNumber, cmBrand :
brand , cmModel : model, cmQuantity : availableQuantity )
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status != StatusConstants.MATCHED, brand ==
cmBrand, model == cmModel, availableQuantity == cmQuantity )
then
System.out.println(StatusConstants.MATCHED);
MatchingOutput output =
buildMatchingOutput(
rtvDetailLine.getBrand(),
rtvDetailLine.getClazz(),
cmDetailLine.getLineNumber(),
cmDetailLine.getCmNumber(),
(String)null, // defTag
rtvDetailLine.getEffectivePrice(),
(BigDecimal)null, // keyRecNo
rtvDetailLine.getItemCost(),
rtvDetailLine.getAvailableQuantity(),
rtvDetailLine.getModel(),
(String)null, // originalRepaymentCode
(BigDecimal)null, // rrLineNumber
rtvDetailLine.getLineNumber(),
rtvDetailLine.getRtvNumber(),
StatusConstants.MATCHED,
DocumentTypes.RTV_CM,
(String)null); // vendorNumber
matchedList.add(output);
cmDetailLine.setAvailableQuantity(Constants.NO_MORE_QUANTITY);
cmDetailLine.setStatus(StatusConstants.MATCHED);
rtvDetailLine.setAvailableQuantity(Constants.NO_MORE_QUANTITY);
rtvDetailLine.setStatus(StatusConstants.MATCHED);
end
rule "RNR Qty EQ RTV Qty"
salience 10
when
rnrDetailLine : DetailLine(keyRecNo != null, lineNumber != null,
status != StatusConstants.MATCHED, cmRtvNumber : cmRtvNumber, cmBrand :
brand , cmModel : model, cmQuantity : availableQuantity )
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status != StatusConstants.MATCHED, brand ==
cmBrand, model == cmModel, availableQuantity == cmQuantity )
then
System.out.println(StatusConstants.MATCHED);
MatchingOutput output =
buildMatchingOutput(
rtvDetailLine.getBrand(),
rtvDetailLine.getClazz(),
(BigDecimal)null, // cmDetailLine.getLineNumber(),
(String)null, // cmDetailLine.getCmNumber(),
(String)null, // defTag
rtvDetailLine.getEffectivePrice(),
rnrDetailLine.getKeyRecNo(), // keyRecNo
rtvDetailLine.getItemCost(),
rtvDetailLine.getAvailableQuantity(),
rtvDetailLine.getModel(),
(String)null, // originalRepaymentCode
rnrDetailLine.getLineNumber(), // rrLineNumber
rtvDetailLine.getLineNumber(),
rtvDetailLine.getRtvNumber(),
StatusConstants.MATCHED,
DocumentTypes.RTV_RR,
(String)null); // vendorNumber
matchedList.add(output);
rnrDetailLine.setAvailableQuantity(Constants.NO_MORE_QUANTITY);
rnrDetailLine.setStatus(StatusConstants.MATCHED);
rtvDetailLine.setAvailableQuantity(Constants.NO_MORE_QUANTITY);
rtvDetailLine.setStatus(StatusConstants.MATCHED);
end
#created on: Apr 10, 2007
package com.circuitcity.rtvcrms.rules
#list any import classes here.
import java.math.BigDecimal;
import com.circuitcity.rtvcrms.bw.ModelDiscrepancyOutput;
import com.circuitcity.rtvcrms.bw.StatusConstants;
import com.circuitcity.rtvcrms.Adjustment;
import com.circuitcity.rtvcrms.DetailLine;
import com.circuitcity.rtvcrms.RepaymentCode;
import com.circuitcity.rtvcrms.MatchingOutput;
import org.drools.WorkingMemory;
import org.drools.QueryResults;
import org.drools.QueryResult;
import java.util.Iterator;
#declare any global variables here
rule "Sum CM"
salience 90
when
mdOutput : ModelDiscrepancyOutput ()
repaymentCode : RepaymentCode( code == "MD")
cmAdjustment : Adjustment(cmNumber != null, lineNumber != null,
originalRepaymentCode == "MD" )
then
System.out.println("Sum CM");
mdOutput.setSumCmAndRnr(cmAdjustment.getAvailableQuantity());
end
Any thoughts?
17 years, 5 months
Time constrained rules
by Jason Vasquez
Hi all,
I need a set of rules to fire on time-based criteria. I have a
'Clock' object in working memory, along with an unknown number of
'TestObject's, each of which can report its 'age'. At some interval,
I modify the Clock object in working memory, and then fire the
rules. As a start (which I'm certain shouldn't work anyway), I'm
playing around with a rule like this:
rule "remove objects older than 2 seconds"
when
Clock()
$to : TestObject( ageInMillis > 2000 )
then
System.out.println(new java.util.Date() + " ========= Retracting " +
$to);
retract($to);
end
It appears that the RHS is never executed, presumably because
TestObjects were not modified. (I'm new to JBossRules, so I'm
unclear on that )
Alternatively, I could just remove the Clock() constraint and iterate
an external collection of TestObject's, marking each object as
modified. Just looking for the best way here...
Thanks,
-jason
17 years, 5 months
Generics support in conditions?
by Emily Harsh
Hello,
I'm using Drools 4.0M3. Several of the objects in our object model take
advantage of generics. I was able to utilize generics in the consequences
by setting the Java language level to 1.5 in the
PackageBuilderConfiguration, however I would also like to optimize my rule
activations by using the concrete types in the conditions. I'm assuming
this is not currently supported since I get the following error when I try
to specify the concrete type in the condition:
mismatched token: [@345,1242:1242='<',<78>,30:15]; expecting type
LEFT_PAREN[30,45]
My working rule uses the following syntax:
rule "Test Generics"
when
Span () # 4.0: Can we use concrete type Span<Integer>?
then
System.out.println("RULE: Matched Span()");
end
I would like to be able to specify the concrete type like this:
rule "Test Generics 2"
when
Span<Integer> ()
then
System.out.println("RULE: Matched Span<Integer>()");
end
Our object model uses the generic type "Span" heavily. I am hoping that I
will be able to reduce the number of rule activations by specifying the
concrete type in the condition.
Any chance this will be available in the 4.0 general release?
Thanks!
Emily
17 years, 5 months
Re: Fun with JAXB
by Matt Geis
Suggestion: Instead of using XMLBeans for your XML serialization/deserialization, use JAXB 2.0. You can get it to use POJO's and annotations (a little more work than doing a straight codegen from an xml schema, but still doable), and JBossRules should have no problem subclassing/overriding, as you will be able to make sure your methods aren't declared 'final' .
Matt
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/
17 years, 5 months
Unresolved Object Reference
by Narendra Valada
* Hello,
I am getting an "Unable to resolve object type" error on certain XML Bean
generated inner classes. I get this error only on inner classes that have
been defined within other inner classes. Please see example below.
Is this a known limitation of JBoss Rules (I am using JBOSS Rules 3.0.6) or
the JANINO compiler?
Thanks.
package com.sample;
public class Outer{
public class Inner {
public boolean inner=false;
public class InnerInner {
}
}
}
package* com.sample
*
import* com.sample.Outer1.Inner.InnerInner;
*
rule* "Hello World 1"
*when
*
InnerInner()
*then
*
System.out.println("");
*
end
*
17 years, 5 months
Drools inside Netbeans module
by Andreas Boehm
Hello all,
I'm using Drools 4.0.0.12865MR3 , Netbeans Platform 5.5 and JDK 1.6.
When trying to instantiate a org.drools.compiler.PackageBuilder inside a
Netbeans module I get the following exception:
org.drools.RuntimeDroolsException:
Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialect:java'
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(PackageBuilderConfiguration.java:156)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:131)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:84)
Maybe this seems to be a ClassLoader issue.
Regards,
Andreas Boehm
17 years, 5 months
Using JSR-94 through FIT
by Natraj Gudla
Hi Mark,
I am using the FIT for rules to test my rules. As the code is using JSR-94 i
found a situation which you might help me resolve. Using the JSR-94
implementation classes, how can i first declare the globals on a package and
then set into the working memory. When i open up the source code i dont see
appropriate methods which can do this for me.
There is a map which can be passed while creating a RuleExecutionSet which i
suppose is allowed to carry only the "source" and the "dsl" key value pairs.
I understand that the globals concept is specific to Drools, but is there a
way we can address this within the JSR-94 implementation classes.
Thanks
Natraj Gudla.
17 years, 5 months
Fun with JAXB
by Ronald R. DiFrango
All,
I am using JAXB classes as my model objects that are getting passed into the
rules engine. I get the exception below. Here is how I am loading the
rules and adding the objects into working memory:
try
{
builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader(
RtvDecisionEngine.class.getResourceAsStream("rtv.drl" ) ) );
builder.addPackageFromDrl( new InputStreamReader(
RtvDecisionEngine.class.getResourceAsStream("
modelDiscrepancyRules.drl" ) ) );
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( builder.getPackage() );
}
catch(Exception e)
{
throw new RuntimeException("Failure loading the Rules", e);
}
final StatefulSession session = ruleBase.newStatefulSession();
DetailLine line = rtvLines[i];
session.insert(line);
Ron
--------------------------------------------------- Exception
---------------------------------------------------
Exception in thread "main" java.lang.VerifyError: class
com.circuitcity.rtvcrms.impl.DetailLineDocumentImpl$DetailLineImplShadowProxyoverrides
final method .
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
at org.drools.rule.MapBackedClassLoader.fastFindClass(
MapBackedClassLoader.java:40)
at org.drools.rule.MapBackedClassLoader.loadClass(
MapBackedClassLoader.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.drools.reteoo.Rete$ObjectTypeConf.<init>(Rete.java:352)
at org.drools.reteoo.Rete.assertObject(Rete.java:152)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java
:190)
at org.drools.reteoo.ReteooWorkingMemory.doInsert(
ReteooWorkingMemory.java:70)
at org.drools.common.AbstractWorkingMemory.insert(
AbstractWorkingMemory.java:772)
at org.drools.common.AbstractWorkingMemory.insert(
AbstractWorkingMemory.java:584)
at com.circuitcity.rtvcrms.rules.RtvDecisionEngine.processDetailLines(
RtvDecisionEngine.java:95)
at com.circuitcity.rtvcrms.rules.RtvDecisionEngine.executeRules(
RtvDecisionEngine.java:64)
at com.circuitcity.rtvcrms.test.MainBasedTester.main(
MainBasedTester.java:34)
17 years, 5 months
order of rules firing
by Smitha Bhat
Hi,
I am new to JBoss rules.
My drl file is not resulting in the functionality that I am expecting.
I know that I shouldn't be counting on the rules firing in a particular order, but I find that as I debug my code, the 'when' of the 3 rules are evaluated first, and then the 'then's. For eg. the SetWatch gets called after DistanceKm(Rule1), DistanceKm(Rule2) and CountWatching(rule3) are called. I expected SetWatch to get called after DistanceKm of Rule2 got called i.e. I expected the 'when' and the 'then' to get evaluated sequentially. Is my understanding wrong? I tried setting the salience of the 3 rules, but I get the same behaviour. Is there something else I need to do, to get the functionality I need?
Thanks
The 3 rules in my drl as given below.
rule "Rule1"
when
$GeoPosition1 : GeoPosition()
$GeoPosition2 : GeoPosition()
eval(util.StringEqual($GeoPosition1.getType(), "PRPT"))
eval(util.StringEqual($GeoPosition2.getType(), "SI"))
eval(util.DistanceKm($GeoPosition1, $GeoPosition2) > 100.0)
eval(util.Watching($GeoPosition1, $GeoPosition2))
then
util.ClearWatch($GeoPosition1, $GeoPosition2);
end
rule "Rule2"
when
$GeoPosition1 : GeoPosition()
$GeoPosition2 : GeoPosition()
eval(util.StringEqual($GeoPosition1.getType(), "PRPT"))
eval(util.StringEqual($GeoPosition2.getType(), "SI"))
eval(util.DistanceKm($GeoPosition1, $GeoPosition2) <= 100.0)
eval(! util.Watching($GeoPosition1, $GeoPosition2))
then
util.SetWatch($GeoPosition1, $GeoPosition2);
end
rule "Rule3"
when
$GeoPosition1 : GeoPosition()
eval(util.StringEqual($GeoPosition1.getType(), "PRPT"))
eval(util.CountWatching($GeoPosition1) >= 1)
then
util.SetThreat($GeoPosition1, 1.0);
util.SetColor($GeoPosition1, "red");
end
---------------------------------
Got a little couch potato?
Check out fun summer activities for kids.
17 years, 5 months