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/
16 years, 3 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
16 years, 3 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.
=
16 years, 3 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.
16 years, 3 months
Running Sub-process only once in rule flow
by Adeyinka Timi
Hi,
Is it possible to set some kind of RUN-ONLY-ONCE restriction on a
sub-process in a rule flow, to avoid running this process multiple times in
the case of a cycle in the rule-flow?
-Ade
16 years, 3 months
Load balancing, fail-over, replication
by Bertrand Grottier
Hello,
I am evaluating the possible use of Drools to implement a pricing engine. Until now, I have developped my prototypes on my own computer; everything was fine.
However, if Drools is retained, it will be used in a shared environment. More precisely, a shared platform is provided for different customers, each one having its own set of rules. This raises issues such as load balancing, replication and so on.
Which architecture is recommended ? How can these issues be addressed ?
This is very fuzzy to me. I am not even sure that they are Drools related...
Thank you in advance for your help.
Regards,
Benoît
_________________________________________________________________
Consultez vos emails Orange, Gmail, Yahoo!, Free ... directement depuis HOTMAIL !
http://www.windowslive.fr/hotmail/agregation/
16 years, 3 months
Drools3 syntax fails in Drools5
by agopalkr
I am trying to migrate from Drools3 to Drools
There is one particular syntax which works in Drools3 but not in Drools5.
rule "Test Long2"
when
//Gives error in D5
m : MyLongValue(id1)
then
System.out.println("did it2:::::" + m);
end
The question I have is
1. What is the meaning of the syntax MyLongValue(id1) ?
2. What is the equivalent syntax in Drools5?
MyLongValue {
private Long id1;
public void setId1(Long x) {
id1 = x;
}
public Long getId1() {
return id1;
}
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools3-syntax-fails-...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 3 months
RPC call exception with drools guvnor
by Dominik Hüttner
Hi,
I use drools guvnor first version 5.1.0, but now I have to use 5.0.1.
On the PC, it has to work on, the following error is produced, when I enter
the drools webpage:
22.04.2010 14:24:03 org.apache.catalina.core.ApplicationContext log
SCHWERWIEGEND: Exception while dispatching incoming RPC call
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.extract(
ServerSerializationStreamReader.java:617)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readInt(
ServerSerializationStreamReader.java:432)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.prepar
eToRead(AbstractSerializationStreamReader.java:38)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.prepareT
oRead(ServerSerializationStreamReader.java:383)
at
com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:234)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServic
eServlet.java:163)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServ
let.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at
org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServle
tRequest.java:53)
at
org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:583)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
That computer has Windows XP Prof SP3, Tomcat 6.0.20, Java jdk 6.0 update
17. The same error occurs with the jboss standalone. Version 5.1.0 works
fine.
On another computer, that is configured nearly the same (WinXP prof SP3,
Tomcat 6.0.20, java jdk 6.0 update 7) all works fine.
Maybe someone can even give me an advise, what could be the problem, or
maybe have a solution.
Kind regards,
Dominik
16 years, 3 months
Newbie on drools and servlets
by kuena
Hi,
I know a question has been asked before about drools and servlets, so I
apologise in advance. May someone please advice me on the best way of making
Drools and servlets friends in my application ;-) I want to use drools to
re-implement the servlet shown below. I have also attached the flow.
In brief my scenario works as follows:
User submits a form to request info; result map is returned; if size >3
refine else return results. Refine will require a page to be generated
asking user how to refine. The user answer will then be used to generate
result.
I have a feeling I might just need to add another node (e.g. event wait or
human task) between the refine action and the rule flow group node. Would
want to avoid that but not sure how will resume flow after refine. I would
be grateful for any pointers.
http://n3.nabble.com/forum/FileDownload.jtp?type=n&id=742273&name=flow.png
public class GeneratorServlet extends HttpServlet {
//declarations
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
//declarations
if(request.getAttribute("resultsMap") != null){
map = (Map) request.getAttribute("resultsMap");
//Render results i.e. present results to user if list is
short
if(map.size() <= maxOutput){
htmlPage.render(map, out, templatePath);
}
//list is long, ask how to shorten the list
else if (map.size() > maxOutput){
dialogSession.setAttribute("storedResultsMap", map);
htmlPage.refine(map, out, templatePath);
}
}
else{ // resultsMap is null
if(dialogSession.getAttribute("storedResultsMap")!= null){
map = (Map)
dialogSession.getAttribute("storedResultsMap");
String criteriaSelection =
request.getParameter("refineChoice");
if(criteriaSelection.equalsIgnoreCase("choice1")){
htmlPage.render(choice1Map, out, templatePath);
}
else if(criteriaSelection.equalsIgnoreCase("choice2")){
htmlPage.render(choice2Map, out, templatePath);
}
else {
htmlPage.render(map, out, templatePath);
}
}
}
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Newbie-on-drools-and-...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 3 months