Help Needed on BRMS with Tomcat
by SB.Raghavendra
Hi All,
Iam very new to Drools BRMS.In one of the project we are implementing
drools.Currentluy iam working on BRMS.I have downloaded Insurance Example
from Jboss and deployed in BRMS.I have downloaded Binary package to
"c:\Raghu".Now i want to use this downloaded binary package in one of my
rule project and wants to execute.I written following lines of code in the
main executable class :
*
package* com.test;
*
import* java.io.FileInputStream;
*
import* java.io.InputStreamReader;
*
import* java.io.Reader;
*
import* org.drools.RuleBase;
*
import* org.drools.RuleBaseFactory;
*
import* org.drools.StatefulSession;
*
import* org.drools.compiler.PackageBuilder;
*public* *class* Test1 {
/**
* *@param* args
*/
*public* *static* *void* main(String[] args) *throws* Exception{
// *TODO* Auto-generated method stub
System.*out*.println("Method Starts...");
PackageBuilder builder = *new* PackageBuilder();
Reader source = *new* InputStreamReader(*new* FileInputStream("
testpackage.pkg"));
System.*out*.println("Got source..");
//PackageBuilder builder = new PackageBuilder(new
Package("/testpackage.pkg"));
builder.addPackageFromDrl(source);
//builder.addPackage(new PackageDescr("/testpackage.pkg"));
System.*out*.println("After adding package : "+builder.getPackage());
RuleBase ruleBase = RuleBaseFactory.*newRuleBase*();
ruleBase.addPackage(builder.getPackage());
StatefulSession session = ruleBase.newStatefulSession();
//RuleAgent.
Person adult = *new* Person("Raghu",25);
//Person child = new Person("John",12);
session.insert(adult);
session.fireAllRules();
System.*out*.println("Method Ends...");
}
}
But iam getting follwing error on console :
Exception in thread "main" *
org.drools.compiler.PackageBuilder$MissingPackageNameException*: Missing
package name for rule package.
at org.drools.compiler.PackageBuilder.validatePackageName(*
PackageBuilder.java:320*)
at org.drools.compiler.PackageBuilder.addPackage(*PackageBuilder.java:236*)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(*PackageBuilder.java
:167*)
at com.test.Test1.main(*Test1.java:29*)
I kept downloaded pkg in the Rules project.
Iam trying to execute in Eclipse.Tomcat version 6.016.Could you please let
me know how to resolve the isse....
Also Please let me know how to use the Binay package of BRMS..
--
Regards,
SB.Raghavendra.
16 years, 9 months
Rules syntax checking
by Jai Vasanth
Hi,
Is there any syntax checker for drools that not only checks for rule syntax
but also checks the presence of used attribute variables in the
corresponding fact objects?
Thanks
Jai
16 years, 9 months
Serializing WorkingMemory Problem.
by Pedro Costa
Hi All,
When serializing a working memory I get the following error:
Caused by: java.io.NotSerializableException:
org.drools.util.AbstractHashTable$SingleIndex
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java
:1081)
at java.io.ObjectOutputStream.defaultWriteFields(
ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(
ObjectOutputStream.java:1347)
at java.io.ObjectOutputStream.writeOrdinaryObject(
ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java
:1079)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java
:1251)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java
:1075)
at java.io.ObjectOutputStream.defaultWriteFields(
ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(
ObjectOutputStream.java:1347)
............
I checked the docs and org.drools.util.AbstractHashTable$SingleIndex is not
serializable ...
Any ideas how I can workarround this one??
Thanks!
Pedro.
16 years, 9 months
Import rules written in Eclipse into the BRMS
by Nicolas Baron
Hello guys,
I'm working on a little project (1 ruleflow, 2 - 3 decision tables and about
5 rules) using JBoss Rules 4.0.4. I'm looking for a way to import this
components, initially developed in Eclipse. I've successfully imported the
decision tables, the domain model and the ruleflow but I cannot find a way
to import rules and dsl files (except a copy / paste of each element). Could
you indicate me the best way to do it ?
Thanks in advance,
Nicolas
16 years, 9 months
Issues with float/double constants
by Andrey Grin
Hi,
I have two issues with float/double constants. In both cases dialect is set
to MVEL
Issue 1
If I use a comparison operator with the Double value it doesn't seem to work
correctly w/o brackets in the right part of the expression:
Example:
I have a condition like:
NumberVariable( owner == $a, name == "PTI", value > 0.5)
In the class NumberVariable the method getValue() is declared as follows:
public Number getValue();
In the working memory I have an instance with name == "PTI" and value ==
0.9633716684527102 ( actual type of the value is Double).
And the rule consequence is not executed.
If I change it and add brackets around the constant everything works
correctly:
NumberVariable( owner == $a, name == "PTI", value > (0.5) )
There is similar example in drools documentation (w/o brackets):
Cheese( type == "stilton", price < 10, age == "mature" )
I assume that in this example the property has a primitive type and in my
case autoboxing is involved, but why brackets are necessary in my case?
Issue 2
I have a rule:
rule "Determine min PRI for for PROD2" ruleflow-group
"budget_calculated_variables_appl"
when
$a: RetailApplication( )
StringVariable(name=="prodid", value matches CONST.PROD2)
then
insert(new NumberVariable("minPTI", 0.6, $a));
end
Initially I had only one constructor for NumberVariable:
public NumberVariable(String pName, Number pValue, Object pOwner)
But MVEL couldn't find this constructor when "then" part was executed
(runtime exception).
The problem was solved when I added another constructor:
public NumberVariable(String pName, float pValue, Object pOwner)
Java compiler accepts identical code when only first constructor is there:
NumberVariable nv = new NumberVariable("minPTI", 0.6, null);
Drools version: 4.04, Java version: 1.6
Thanks,
Andrey.
16 years, 9 months