Re: [rules-users] Very basic running of drools 5, basic setup and quickstart
by Greg Barton
The best documentation to read would be the maven docs:
http://maven.apache.org/
But if you drop the attached pom.xml into a project created by drools' eclipse plugin it'll work fine. type "mvn clean install" from the project home directory and it'll build. (After downloading half the known universe...)
--- On Thu, 4/22/10, Berlin Brown <berlin.brown(a)gmail.com> wrote:
From: Berlin Brown <berlin.brown(a)gmail.com>
Subject: Re: [rules-users] Very basic running of drools 5, basic setup and quickstart
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Date: Thursday, April 22, 2010, 5:11 PM
Is there documentation on how to do this, including a full example. I saw the pom file, but still don't know the run/compile targets?
2010/4/22 Greg Barton <greg_barton(a)yahoo.com>
Have you ever thought of using maven? Your problem is no doubt with including the transitive dependencies of the drools libraries, which maven would do for you automatically. Here are the jars that were included automatically in a project I compiled with drools-core, drools-compiler, drools-api, all 5.0.1:
antlr-runtime-3.1.1.jar
core-3.4.2.v_883_R34x.jar
drools-api-5.0.1.jar
drools-compiler-5.0.1.jar
drools-core-5.0.1.jar
janino-2.5.15.jar
joda-time-1.6.jar
jsap-2.1.jar
mvel2-2.0.10.jar
This resulted from a dependencies section in the maven pom that had just this in it:
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-api</artifactId>
<version>5.0.1</version>
</dependency>
</dependencies>
So I suggest you give maven a try. It makes this easy. :)
--- On Wed, 4/21/10,
Berlin Brown <berlin.brown(a)gmail.com> wrote:
From: Berlin Brown <berlin.brown(a)gmail.com>
Subject: [rules-users] Very basic running of drools 5, basic setup and quickstart
To: rules-users(a)lists.jboss.org
Date: Wednesday, April 21, 2010, 12:54 AM
Is there a more comprehensive quick start for drools 5. I was attempting to run the simple Hello World .drl rule but I wanted to do it through an ant script, possibly with just javac/java:
I get the following error: Note: I don't am running completely without Eclipse or any other IDE:
test:
[java] Exception in thread "main" org.drools.RuntimeDroolsException: Unable to load d
ialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule
.builder.dialect.java.JavaDialectConfiguration'
[java] at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuild
erConfiguration.java:274)
[java] at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurati
onMap(PackageBuilderConfiguration.java:259)
[java] at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConf
iguration.java:176)
[java] at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderCo
nfiguration.java:153)
[java] at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:242)
[java] at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:142)
[java] at org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuilde
r(KnowledgeBuilderProviderImpl.java:29)
[java] at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(Knowledg
eBuilderFactory.java:29)
[java] at org.berlin.rpg.rules.Rules.rules(Rules.java:33)
[java] at org.berlin.rpg.rules.Rules.main(Rules.java:73)
[java] Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not in the
classpath
[java] at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompil
er(JavaDialectConfiguration.java:94)
[java] at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(Java
DialectConfiguration.java:55)
[java] at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuild
erConfiguration.java:270)
[java] ... 9 more
[java] Java Result: 1
...
...
I do include the following libraries with my javac and java target:
<path id="classpath">
<pathelement location="${lib.dir}" />
<pathelement location="${lib.dir}/drools-api-5.0.1.jar" />
<pathelement location="${lib.dir}/drools-compiler-5.0.1.jar" />
<pathelement location="${lib.dir}/drools-core-5.0.1.jar" />
<pathelement location="${lib.dir}/janino-2.5.15.jar" />
</path>
Here is the Java code that is throwing the error. I commented out the java.compiler code, that didn't work either.
public void rules() {
/*
final Properties properties = new Properties();
properties.setProperty( "drools.dialect.java.compiler", "JANINO" );
PackageBuilderConfiguration cfg = new PackageBuilderConfiguration( properties );
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
cfg.getDialectConfiguration( "java" );
*/
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl", Rules.class), ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile \"HelloWorld.drl\".");
}
// Get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
// Add the packages to a knowledgebase (deploy the knowledge packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.setGlobal("list", new ArrayList<Object>());
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());
// Setup the audit logging
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/helloworld");
final Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ksession.insert(message);
ksession.fireAllRules();
logger.close();
ksession.dispose();
}
...
Here I don't think Ant is relevant because I have fork set to true:
<target name="test" depends="compile">
<java classname="org.berlin.rpg.rules.Rules" fork="true">
<classpath refid="classpath.rt" />
<classpath>
<pathelement location="${basedir}" />
<pathelement location="${build.classes.dir}" />
</classpath>
</java>
</target>
The error is thrown at line 1.
Basically, I haven't done anything except call
final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
I am running with Windows XP, Java6, and within Ant.1.7.
--
Berlin Brown (berlin dot brown at gmail.com)
http://botnode.com
http://berlinbrowndev.blogspot.com/
-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Berlin Brown (berlin dot brown at gmail.com)
http://botnode.com
http://berlinbrowndev.blogspot.com/
-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
14 years, 8 months
AUTO: Nilima R is out of the office (returning 05/03/2010)
by Nilima R
I am out of the office until 05/03/2010.
Note: This is an automated response to your message "rules-users Digest,
Vol 41, Issue 111" sent on 4/23/10 20:00:16.
This is the only notification you will receive while this person is away.
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 8 months
Drools Flow: Another problem with Human Task
by HMandic
Hi,
I need some help here.
I have a simple process with one human task. That human task work item has
all the necessary fields filled (actorid, id, name, etc.). When I start that
process it gets to that human task and fills everything it needs in the
database (Postgres) through hibernate. Up until here it works fine.
But then when I need to get a list of tasks for some particular user it
breaks because the task list is empty.
The code looks like this:
*******************************************************************************
BlockingTaskSummaryResponseHandler responseHandler = new
BlockingTaskSummaryResponseHandler();
client.getTasksAssignedAsPotentialOwner("thatUserOfMine", "en-UK",
responseHandler);
List<TaskSummary> tasks = responseHandler.getResults();
TaskSummary task = tasks.get(0);
*******************************************************************************
In that last line I get java.lang.IndexOutOfBoundsException, of course...
Now here's the problem - hibernate generates the following SQL:
*******************************************************************************
[LOG MESSAGE] Message receieved on server :
QueryTasksAssignedAsPotentialOwner
select
task0_.id as col_0_0_,
i18ntext4_.text as col_1_0_,
subjects3_.text as col_2_0_,
i18ntext5_.text as col_3_0_,
task0_.status as col_4_0_,
task0_.priority as col_5_0_,
task0_.skipable as col_6_0_,
task0_.actualOwner_id as col_7_0_,
task0_.createdBy_id as col_8_0_,
task0_.createdOn as col_9_0_,
task0_.activationTime as col_10_0_,
task0_.expirationTime as col_11_0_
from
test1.Task task0_
left outer join
test1.OrganizationalEntity user1_ on task0_.createdBy_id=user1_.id
left outer join
test1.OrganizationalEntity user2_ on task0_.actualOwner_id=user2_.id
left outer join
test1.I18NText subjects3_ on task0_.id=subjects3_.Task_Subjects_Id
!!! inner join
test1.OrganizationalEntity user7_ on task0_.actualOwner_id=user7_.id
inner join
test1.OrganizationalEntity user8_ on task0_.createdBy_id=user8_.id
cross join
test1.I18NText i18ntext4_
cross join
test1.I18NText i18ntext5_
cross join
test1.OrganizationalEntity organizati6_
where
organizati6_.id = 'thatUserOfMine'
and (organizati6_.id in (select potentialo9_.entity_id from
test1.PeopleAssignments_PotentialOwners potentialo9_ where
task0_.id=potentialo9_.task_id))
and i18ntext4_.language = 'en-UK'
and (i18ntext4_.id in (select names10_.id from test1.I18NText names10_
where task0_.id=names10_.Task_Names_Id))
and (subjects3_.language = 'en-UK' or (select
count(subjects11_.Task_Subjects_Id) from test1.I18NText subjects11_ where
task0_.id=subjects11_.Task_Subjects_Id) = 0)
and (i18ntext5_.language = 'en-UK'
and (i18ntext5_.id in (select descriptio12_.id from test1.I18NText
descriptio12_ where task0_.id=descriptio12_.Task_Descriptions_Id))
or (select count(descriptio13_.Task_Descriptions_Id) from
test1.I18NText descriptio13_ where
task0_.id=descriptio13_.Task_Descriptions_Id) = 0)
and (task0_.status in ('Created' , 'Ready' , 'Reserved' , 'InProgress' ,
'Suspended'))
and (task0_.expirationTime is null)
;
*******************************************************************************
You will notice the inner join with '!!!' in front of it. That's the reason
why this list is always empty, because at this stage of human task there is
no actual owner, that field is NULL. I've tried different versions of
orm.xml (from 5.0.1, 5.1.0M1 and the latest from trunk) but they all produce
the same error.
Can someone please point out what I'm doing wrong (I'm also not very good
with hibernate).
--
View this message in context: http://n3.nabble.com/Drools-Flow-Another-problem-with-Human-Task-tp724086...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 8 months
Expert: Modify the result of a collect Operation
by Jörg Herbst
Hi,
I'm trying to change the result of a collect operation, is this possible?
This is my sample rule:
rule "Select the only remaining value for
each feature Key"
when
# Check all not selected features
feature : ExpertFeature(selected==false)
# if there is one enable feature select
this one
list : ArrayList (size == 1) from
collect( ExpertFeature(disabled == false, featureKey==feature.featureKey,
selected==false) )
then
# this is not working
modify( list ) {setSelected(true);}
end
Thanks
Joerg
14 years, 8 months
Drools Flow: API for Timers
by tolitius
Hey Drools Crowd,
1. Why is there no simple API to start the Timer(s)?
e.g. ksession.startTimers()
that would encapsulate a low level thread spawning:
new Thread(new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
}).start();
2. Why do these timers _need_ to started by developer? Framework already
knows there are timers, and should start them on "ksession.startProcess".
/Anatoly
--
View this message in context: http://n3.nabble.com/Drools-Flow-API-for-Timers-tp732299p732299.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 8 months
Very basic running of drools 5, basic setup and quickstart
by Berlin Brown
Is there a more comprehensive quick start for drools 5. I was attempting to
run the simple Hello World .drl rule but I wanted to do it through an ant
script, possibly with just javac/java:
I get the following error: Note: I don't am running completely without
Eclipse or any other IDE:
test:
[java] Exception in thread "main" org.drools.RuntimeDroolsException:
Unable to load d
ialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule
.builder.dialect.java.JavaDialectConfiguration'
[java] at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuild
erConfiguration.java:274)
[java] at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurati
onMap(PackageBuilderConfiguration.java:259)
[java] at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConf
iguration.java:176)
[java] at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderCo
nfiguration.java:153)
[java] at
org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:242)
[java] at
org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:142)
[java] at
org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuilde
r(KnowledgeBuilderProviderImpl.java:29)
[java] at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(Knowledg
eBuilderFactory.java:29)
[java] at org.berlin.rpg.rules.Rules.rules(Rules.java:33)
[java] at org.berlin.rpg.rules.Rules.main(Rules.java:73)
[java] Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar
is not in the
classpath
[java] at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompil
er(JavaDialectConfiguration.java:94)
[java] at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(Java
DialectConfiguration.java:55)
[java] at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuild
erConfiguration.java:270)
[java] ... 9 more
[java] Java Result: 1
...
...
I do include the following libraries with my javac and java target:
<path id="classpath">
<pathelement location="${lib.dir}" />
<pathelement location="${lib.dir}/drools-api-5.0.1.jar" />
<pathelement location="${lib.dir}/drools-compiler-5.0.1.jar" />
<pathelement location="${lib.dir}/drools-core-5.0.1.jar" />
<pathelement location="${lib.dir}/janino-2.5.15.jar" />
</path>
Here is the Java code that is throwing the error. I commented out the
java.compiler code, that didn't work either.
public void rules() {
/*
final Properties properties = new Properties();
properties.setProperty( "drools.dialect.java.compiler", "JANINO" );
PackageBuilderConfiguration cfg = new PackageBuilderConfiguration(
properties );
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
cfg.getDialectConfiguration( "java" );
*/
final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl",
Rules.class), ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile
\"HelloWorld.drl\".");
}
// Get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();
// Add the packages to a knowledgebase (deploy the knowledge
packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
final StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
ksession.setGlobal("list", new ArrayList<Object>());
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());
// Setup the audit logging
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/helloworld");
final Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ksession.insert(message);
ksession.fireAllRules();
logger.close();
ksession.dispose();
}
...
Here I don't think Ant is relevant because I have fork set to true:
<target name="test" depends="compile">
<java classname="org.berlin.rpg.rules.Rules" fork="true">
<classpath refid="classpath.rt" />
<classpath>
<pathelement location="${basedir}" />
<pathelement location="${build.classes.dir}" />
</classpath>
</java>
</target>
The error is thrown at line 1.
Basically, I haven't done anything except call
final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
I am running with Windows XP, Java6, and within Ant.1.7.
--
Berlin Brown (berlin dot brown at gmail.com)
http://botnode.com
http://berlinbrowndev.blogspot.com/
14 years, 8 months
Declaration of Metadata tags for External Data Models in Guvnor.
by Meyer, David A
I have a set of externally defined java beans that are utilized elsewhere in
the overarching application, and would like to declare these external
classes as events within drools. I am able declare these objects as events,
and compile a drools DRL file, and execute the rules. When the same DRL is
imported into the Guvnor, the resulting package "PKG" issues an "unable to
define Type Declaration class {object}" exception error. Preliminary
investigation has turned up JIRA #'s GUVNOR-379
<https://jira.jboss.org/jira/browse/GUVNOR-379>, and BRMS-144
<https://jira.jboss.org/jira/browse/BRMS-144>, that indicate this behavior
has been identified, but no solution is presented. The Drools documentation
for both the expert and fusion component functionality indicates that
metadata can be declared with or without actually declaring fields. This
capability is key to allowing the utilization of externally defined data
model objects within drools.
Example DRL declaration section that works as specified when the DRL file is
built into a knowledge base, but does not work when the Guvnor package is
built in to a knowledge base. I am currently utilizing Drools 5.0.1 in both
the IDE development environment as well as the Guvnor deployment
environment.
begin data model fragment .
Import com.datamodel.MyEvent;
Declare MyEvent
@role(event)
@timestamp(eventDate)
end
. end data model fragment
Seems that the data model definition shown above should produce the same
results whether using the DRL resource type, or the PKG resource produced by
the Guvnor package builder. Are these JIRA's closed in 5.1 or are they
still pending. The system utilizing the Guvnor should allow deployment of
DRLs to the GUVNOR without change, this bug does not allow that.
David A. Meyer
System Engineer
I&SS Mission Operations - Colorado
Boeing Defense, Space & Security
The Boeing Company
Telephone 303-307-5836
14 years, 8 months
Drools Expert (Rule Engine) - Performance Tips
by andre.fonseca@mail.com
Hi all,
I need to perform a test in the Drools Rule Engine. This test is intended to discover the SLA for Rule Processing.
The scenario that I have is:
- My Knowledge Database will have almost 200 million records.
- There will be a full monthly charge and a short diary charge in this KD.
- The Rules are not so complex. (6 or 7 levels at most)
How can I perform this test? Could you please give me some advices?
Another question: How Drools integrate with the Knowledge Database assuming this is already created? (Actually this KD will be created using a ETL process)
Thanks for your support, any advice will be appreciated.
=
14 years, 8 months
RuntimeDroolsException as Solver concludes execution
by dweppenaar
Hi.
I am experiencing the following exception:
org.drools.RuntimeDroolsException: Exception executing ReturnValue
constraint org.drools.rule.ReturnValueRestriction@a5f6c234 :
java.lang.NullPointerException.
The rule that is causing the exception to occur is the following:
rule "spreadOvertime"
when
$violatingTask :
MaintenanceTask(eval(maintenanceSlot.getAvailability() == 1), motor != null,
maintenanceTechnician != null, $overtimeTaskID : id);
ArrayList( $numberOfViolations : size ) from collect(
MaintenanceTask(
id == ($overtimeTaskID + 1) ||
id == ($overtimeTaskID + 2) ||
id == ($overtimeTaskID - 1) ||
id == ($overtimeTaskID - 2),
eval(maintenanceSlot.getAvailability() >= 1) ) );
then
insertLogical(new IntConstraintOccurrence("spreadOvertime",
ConstraintType.NEGATIVE_SOFT,
$numberOfViolations, $violatingTask, $numberOfViolations));
//System.out.println("Rule Fired: spreadOvertime ( number of
violations:" + $numberOfViolations + " for task " + $violatingTask + ")");
end
The purpose of the rule is to spread the closer to normal maintenance
shifts.
Just to clarrify what the objects are:
MaintenanceTask: Consists of a MaintenanceSlot, MaintenanceTechnician and
Motor
MaintenanceSlot: Day, Timeslot, Availability and Index
The 'availability' of a MaintenanceSlot specifies whether it is considered
Overtime, ProductionTime or Normal Maintenance
This exception is thrown at the end of solving as the solver (I presume) is
supposed to return the best solution. The score is calculating and updating
but at the end of the specified step count, this exception occurs.
If I comment this rule out, no exception.
Any help would be appreciated!
Regards,
De Ville
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/RuntimeDroolsExceptio...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 8 months