Problem with DSL in Drools 4.0.3
by tansey
I'm new to Drools, and I've setup the latest version of it in Eclipse 3.2.
I'm having trouble whenever I try to use a DSL though. I took the standard
Hello World example and added the 'mylang.dsl' file, and changed the lines
in DroolsTest.readRule() as follows:
private static RuleBase readRule() throws Exception {
//read in the source
Reader source = new InputStreamReader(
DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );
//optionally read in the DSL (if you are using it).
Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream(
"/mylang.dsl" ) );
//Use package builder to build up a rule package.
//An alternative lower level class called "DrlParser" can also be used...
PackageBuilder builder = new PackageBuilder();
//this wil parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for normal DRL.
//builder.addPackageFromDrl( source );
//Use the following instead of above if you are using a DSL:
builder.addPackageFromDrl( source, dsl );
//get the compiled package (which is serializable)
Package pkg = builder.getPackage();
//add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
Even if I remove all rules from the dsl file, it still gives me the same
error:
org.drools.rule.InvalidRulePackage:
[4] Unable to expand: m : Message( status == Message.HELLO, message :
message )
[6] Unable to expand: System.out.println( message );
[7] Unable to expand: m.setMessage( "Goodbye cruel world" );
[8] Unable to expand: m.setStatus( Message.GOODBYE );
[9] Unable to expand: update( m );
[5] Unable to expand: m : Message( status == Message.GOODBYE, message :
message )
[7] Unable to expand: System.out.println( message );
[8] Unable to expand: m.setMessage( message );
at org.drools.rule.Package.checkValidity(Package.java:424)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:361)
at com.sample.DroolsTest.readRule(DroolsTest.java:64)
at com.sample.DroolsTest.main(DroolsTest.java:21)
Anyone have an idea of what's wrong?
--
View this message in context: http://www.nabble.com/Problem-with-DSL-in-Drools-4.0.3-tf4722439.html#a13...
Sent from the drools - user mailing list archive at Nabble.com.
17 years
Initialize Global
by drools_user
How do I initialize a global fact in the drl file? I want use the JSR94 API
and avoid using the Drools API inside the Java code. I would like to access
the same variable every execution of a stateful session without having to
reinstantiate the variable after each execution?
Basically I want to define a global like this:
# Define global variable
global List objectList ;
# Part that does not work
objectList = new ArrayList() ;
objectList.add("1");
objectList.add("2");
Thanks
--
View this message in context: http://www.nabble.com/Initialize-Global-tf4685186.html#a13388685
Sent from the drools - user mailing list archive at Nabble.com.
17 years
RE: JavaConsequenceBuilder.build NullPointerException
by Michael Fuller
I have the following code: (note String[] ruleFiles contains only one
string)
public class Engine {
private static RuleBase ruleBase;
public void start(String[] ruleFiles) throws Exception {
PackageBuilderConfiguration cfg = new
PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
cfg.getDialectConfiguration("java");
javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
PackageBuilder builder = new PackageBuilder(cfg);
for (String file : ruleFiles) {
builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file)));
}
Package pkg = builder.getPackage();
PackageBuilderErrors errors = builder.getErrors();
if (errors.getErrors().length != 0) {
// do something
}
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setAssertBehaviour(RuleBaseConfiguration.AssertBehaviour.EQUALITY);
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
ruleBase.newStatefulSession(false);
}
}
At the builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file))); line
I'm getting the following exception:
java.lang.NullPointerException
at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaCo
nsequenceBuilder.java:54)
at
org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
at
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java
:167)
at
myPackage.rivoli.service.rules.Engine.start(Engine.java:33)
at
myPackage.rivoli.rules.LeaderKingAndHeirTest.setUp(LeaderKingAndHeirTest
.java:26)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
I am using Drools 4.0.3
I have the following jars in my class path:
antlr-runtime-3.0.jar
core-3.2.3.v_686_R32x.jar
drools-compiler-4.0.3.jar
drools-core-4.0.3.jar
mvel14-1.2.10.jar
Any ideas would be helpful. Thanks.
Michael Fuller
"In theory there is no difference between theory and practice. But, in
practice, there is." - Jan L.A. van de Snepscheut
17 years
Problem running JBRMS 4.0.3 on JBoss AS 4.2.1
by Aziz Boxwala
Switching to AS 4.2.0 may not be an easy option for us. Much of our development product development has been done with 4.2.1.
I did not have this problem with BRMS 4.0.0 running on AS 4.2.1.
I should clarify that the exception is thrown when trying to login to the BRMS.
If there is no resolution, is it possible to get to earlier builds (4.0.0 latest, or 4.0.1). The downloads page only lists 4.0.3.
Thanks,
--Aziz
-----------------------------------------------------------------------------------------
Aziz
I have/had the same problem under Windows NT. I never received a
resolution so I just stayed with 4.2.0. It must not work with 4.2.1.
Rod
On Fri, Oct 26, 2007 at 09:27:23AM -0700, Aziz Boxwala wrote:
> I cannot get the BRMS to run on JBoss AS 4.2.1. (on Windows Vista).
>
> Any help/hints to fix this will be appreciated. This is the error I get:
>
> 12:19:03,577 INFO [STDOUT] ERROR 26-10 12:19:03,576
> (Contexts.java:flushAndDestroyContexts:335) could not discover
> transaction status
> 12:19:03,579 INFO [STDOUT] ERROR 26-10 12:19:03,578
> (StandardWrapperValve.java:invoke:278) Servlet.service() for s
> ervlet default threw exception
> java.lang.IllegalStateException: Cannot create a session after the response has
> been committed
> at org.apache.catalina.connector.Request.doGetSession
> (Request.java:2284)
> at org.apache.catalina.connector.Request.getSession(Request.java:2066)
> at org.apache.catalina.connector.RequestFacade.getSession
> (RequestFacade.java:833)
> at org.jboss.seam.servlet.ServletRequestSessionMap.put
> (ServletRequestSessionMap.java:87)
> at org.jboss.seam.servlet.ServletRequestSessionMap.put
> (ServletRequestSessionMap.java:25)
> at org.jboss.seam.contexts.BasicContext.set(BasicContext.java:80)
> at org.jboss.seam.Component.newInstance(Component.java:1980)
> at org.jboss.seam.Component.getInstance(Component.java:1878)
> at org.jboss.seam.Component.getInstance(Component.java:1857)
> at org.jboss.seam.Component.getInstance(Component.java:1834)
> at org.jboss.seam.web.Session.getInstance(Session.java:122)
> at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts
> (Contexts.java:375)
> at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:132)
> at org.jboss.seam.servlet.ContextualHttpServletRequest.run
> (ContextualHttpServletRequest.java:65)
> at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> (ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter
> (ApplicationFilterChain.java:206)
> at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter
> (ReplyHeaderFilter.java:96)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> (ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter
> (ApplicationFilterChain.java:206)
> at org.apache.catalina.core.StandardWrapperValve.invoke
> (StandardWrapperValve.java:230)
> at org.apache.catalina.core.StandardContextValve.invoke
> (StandardContextValve.java:175)
> at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
> (SecurityAssociationValve.java:179)
> at org.jboss.web.tomcat.security.JaccContextValve.invoke
> (JaccContextValve.java:84)
> at org.apache.catalina.core.StandardHostValve.invoke
> (StandardHostValve.java:128)
> at org.apache.catalina.valves.ErrorReportValve.invoke
> (ErrorReportValve.java:104)
> at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke
> (CachedConnectionValve.java:157)
> at org.apache.catalina.core.StandardEngineValve.invoke
> (StandardEngineValve.java:109)
> at org.apache.catalina.connector.CoyoteAdapter.service
> (CoyoteAdapter.java:241)
> at org.apache.coyote.http11.Http11Processor.process
> (Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process
> (Http11Protocol.java:580)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
> (JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:595)
>
> Thanks,
> --Aziz
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
17 years
Problem drools-ant 4.0.2
by Arnaud Bouzinac
I try to generate a pkg file from a drl file
so , i'm using drools-ant task (version 4.0.2)
when i load my pkg file, there's a classcast exception:
java.lang.ClassCastException: org.drools.reteoo.ReteooRuleBase cannot be
cast to org.drools.rule.Package
at org.drools.agent.FileScanner.readPackage(FileScanner.java:109)
at org.drools.agent.FileScanner.getChangeSet(FileScanner.java:79)
at org.drools.agent.FileScanner.loadPackageChanges(FileScanner.java:57)
at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:330)
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:298)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:284)
at org.drools.agent.RuleAgent.init(RuleAgent.java:208)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:176)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:148)
at
fr.biomerieux.qi.algo.common.inferenceengine.InferenceEngineControllerImpl.initializeRuleBaseFromPKG
(InferenceEngineControllerImpl.java:128)
at
fr.biomerieux.qi.algorithms.testcase.inferenceengine.InferenceEngineTestCase.testInferenceEngineCase
(InferenceEngineTestCase.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at fr.biomerieux.junit.BmxTestCase.run(BmxTestCase.java:64)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(
JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:196)
17 years
DroolsTab annoncement
by Ru
Hello rules-users,
DroolsTab (former JBRSTab) - DROOLS BASED SPATIAL SCENARIO SIMULATION
PLUG-IN TO PROTEGE - published on http://oogis.ru/component/
option,com_remository/Itemid,34/func,fileinfo/id,2/lang,en/
New features:
- Drools 4 rule engine support
- Parallel tasks instead of sequential phases in scenarios
- new exciting examples with accent on rule sets authoring
Sincerely,
Ru
Ruslan P. Sorokin sorokin(a)oogis.ru
OOGIS RL http://www.oogis.ru
SPIIRAS http://www.spiiras.nw.ru
St.Petersburg
Russia
17 years
TR : RE : [rules-users] How to dump the class/src generated by .drl file?
by Lafon, olivier
Hi,
I'm currently using Jboss Rules in it's 3.0.6 version, and I can't find the JavaRuleClassBuilder class, is anyone have an idea to recover the generated class from dsl & Drl file? (So helpfull for debugging ^_^).
Thanks
Olivier
--------------------------------------------------------------------------------
De : rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] De la part de Mark Proctor
Envoyé : mardi 7 août 2007 12:27
À : Rules Users List
Objet : Re: [rules-users] How to dump the class/src generated by .drl file?
There is no standard api for this, you would have to get your hands dirty with the source. Look at JavaRuleClassBuilder and you can see where to put your printouts.
Mark
Yang Song wrote:
Greetings everyone,
Does anyone know how to dump the class generated from .drl file to disk? Or even better if the generated Java source file can be dumped?
Looking for some hints here, I got a NPE when firing the rules. However, it is really hard to find out why the NEP was thrown... If I can have the dumped class file, then I can be disassemble it back to Java code.
To debug this rule in Eclipse is a bit difficult here, because the project is a little "big" and we usually use logging to do debugging...
java.lang.NullPointerException
at monitor.Rule_ftp_other_host_alarm_0.consequence(Rule_ftp_other_host_alarm_0.java:23)
at monitor.Rule_ftp_other_host_alarm_0ConsequenceInvoker.evaluate(Rule_ftp_other_host_alarm_0ConsequenceInvoker.java:26)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
at org.drools.common.AbstractWorkingMemory.fireAllRules (AbstractWorkingMemory.java:430)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
at com.monitor.ruleengine.InferenceMachine.fireAllRules(InferenceMachine.java:400)
at com.monitor.ruleengine.InferenceMachine.run(InferenceMachine.java:314)
at java.lang.Thread.run(Thread.java:595)
Thanks very much,
Yang
--------------------------------------------------------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
17 years
how to sort and validate
by Sikkandar Nawabjan
Hi,
I Have 2 types of objects say
AObject1(effdate,terminationdate,status=active)
AObject2(effdate,terminationdate,status=inactive)
AObject3(effdate,terminationdate,status=active)
etc...
BObject(effectivedate,id)
i want to check such a way that BObject's effective date should be fall within a range of AObjects(list of AObjects) miniumeffectivedate and maximumterminationdate when its status Active.
How to write a rule for that
Thanks and Regs,
Basha
17 years
Use only first matching rule
by nechukin
Hi,
I'm looking into the Drools engine for our application, and looks like it's
satisfies the reqirements. The only thing I haven't found still is a
following conflict management model:
If rule_1 (with highest salience) is applicable, STOP applying another
rules.
So the essence is that only 1 or 0 rules should be applied for the
particular entity, not 2 or more.
I'm sure this is supported by engine. Where to look? Tried to scan
ConflictResolving section, but look like it is only about the rules
application order, not more...
Thanks,
Georgy
--
View this message in context: http://www.nabble.com/Use-only-first-matching-rule-tf4710521.html#a13464084
Sent from the drools - user mailing list archive at Nabble.com.
17 years
equality-based assert behavior and findFactHandle
by Adam Lewandowski
If I set my rule base to use equality-based assert behavior, I'm
expecting to be able to use the getFactHandle(object) method to retrieve
a previously asserted fact by providing an equivalent (by equals() and
hashCode()) object as an argument. This appears to not be the case, as
AbstractWorkingMemory uses it's identityMap and associated
IdentityAssertMapComparator to do the getFactHandle lookup instead of
the assertMap and EqualityAssertMapComparator. This causes the lookup to
be done with the system hashCode() method and not the overridden version
supplied in my fact class. The lookup thus fails and returns null.
Is there a way to have getFactHandle or some equivalent code do what I
want? This is with 4.0.3.
Thanks,
Adam Lewandowski
17 years