Rules question
by Yuri de Wit
Is it possible to do something like this with Drools 4.0?
rule
when
p:Parent()
not Child( this in p.children )
then
...
end
I basically dont want to keep a reference fro Child to Parent.
thanks,
17 years, 5 months
Issue with not Fact equality checks?
by Eric Miles
I have a single rule in my test bed as such:
rule "5th Item Not Test"
when
$first : FirstClass($i1 : item1, $i2 : item2, $i3 : item3, $i4 :
item4, $i5 : item5)
not SecondClass(item1 == $i1, item2 == $i2, item3 == $i3, item4 ==
$i4, item5 == $i5)
then
System.out.println("NOT test matched");
end
In the not SecondClass() section of the test, the last equality checks
always fail, no matter what it is. I can switch the order around of the
checks, no matter what the last 2 are, they cause THEN clause to not
fire, even when I am absolutely positive there is not a match. (I can
remove the not and the equality works fine). Is there a limit on the
number of equality tests I can do with a not? It seems as though it is
4. I have attached a test case that can reproduce this (it is different
from my project's code, but I have been able to reproduce this in
multiple projects). It is a maven Eclipse project and includes a junit
with some minor instructions. If these instructions do not make sense,
please email me.
17 years, 5 months
JBossRules and JAVA Servlet / JSP (part2)
by Mohammed JBossRules
2007/7/20, Mohammed JBossRules <jboss.lakehayli(a)gmail.com>:
>
> Hi,
> an other question , when i'm trying to execute the same code in the sample
> test java file provided by the wizard, I get some other errors :
>
> java.lang.NoClassDefFoundError: org/drools/WorkingMemory
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
> at java.lang.Class.getConstructor0(Unknown Source)
> at java.lang.Class.newInstance0 (Unknown Source)
> at java.lang.Class.newInstance(Unknown Source)
> at org.apache.catalina.core.StandardWrapper.loadServlet(
> StandardWrapper.java:1104)
> at org.apache.catalina.core.StandardWrapper.allocate(
> StandardWrapper.java:806)
> at org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:129)
> at org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:175)
> at org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java:128)
> at org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java:104)
> at org.apache.catalina.core.StandardEngineValve.invoke (
> StandardEngineValve.java:109)
> at org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java:261)
> at org.apache.coyote.http11.Http11Processor.process(
> Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process (
> Http11Protocol.java:581)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java
> :447)
> at java.lang.Thread.run(Unknown Source)
>
>
> it works fine if i'm using a simple class, but when i try to use my
> servlet, it falls;
>
> and finally, is it possible to contribute withe a tutorial showing how to
> set up drools on eclipse and running a DroolsTest sample file,(arabic,
> english and frensh version) that's all i can propose for the moment.
>
> thank you.
>
>
>
>
>
>
> 2007/7/20, Mohammed JBossRules <jboss.lakehayli(a)gmail.com>:
> >
> > hello,
> > Thank you all for your replays; as you've suggested, what i should
> > import into my build path was not the core and compiler but all the set
> > contained in the drools library, maybe that would help someone later!
> > here is the list of jars
> > antlr-runtime.jar
> > drools-compiler.jar
> > drools-core.jar
> > drools-decisiontables.jar
> > drools-documentation.jar
> > drools-jsr94.jar
> > jsr94.jar
> > junit.jar
> > jxl.jar
> > mvel14.jar
> > xercesImpl.jar
> > xml-apis.jar
> > xpp3.jar
> > xstream.jar
> > Thankyou Mark for the link
> > with kind regards,
> >
> > ps: tried many times to post this mail yesterday but seems that it
> > doesn't work, sorry if you received it more than once!
> > Mohammed JBossRules wrote:
> > > Hello,
> > >
> > > I'm a new user for JBossRules, and I'm feeling like turning around
> > > since a while, so i thought that sole body could help...
> > > I'm using JBossRules( V4.0.0.12865MR3) on eclipse (Version: 3.3.0Build
> > > id: I20070621-1340) on MS-Windows XP and Java(TM) SE Runtime
> > > Environment (build 1.6.0_01-b06)
> > > now the problem is how to use my rules (simple rules in a DRL file) in
> >
> > > a dynamic project based on JSP/Servlets...
> > > i've imported the compiler, the core, jsr94, decisiontable, and also
> > > the core 3.2.3 jars to my build path , but when i try to execute the
> > > same code i'm having errors like:
> > > The import org.drools cannot be resolved
> > > but i have imported the core!!
> > > what's wrong? help please
> > >
> > > regards
> > > _______________________________________________
> > > rules-users mailing list
> > > rules-users(a)lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> >
> >
>
17 years, 5 months
BRMS import
by Shepherd, Michael
Hi,
Can I import an existing set of JBoss rules (Drools 3) into BRMS?
Thanks,
Mike
17 years, 5 months
How to compare to Class type in LHS??
by Felipe Piccolini
Hi,
Im trying to compare a field to a Class type but when parsing I
get NPE and when I debug,
the constraint is a ReturnValueConstraint but the
restriction.getRequiredDeclarations()
return a Declaration[] array initializated, but empty, so I can't get
the declaration evaluated...
I needed because I'm working on a kind of parser for the rules for
analisys and testing... but using
the already parsed package.
Here is a pseudo rule for test...
rule "Test A"
when
$mf: MyFact(clazz == (SomeClass.class))
then
System.out.println("Test A: OK");
end
Actualy, the rule compiles (with the NPE output, not stackTrace, just
the java.lang.NullPointerException,
and it works fine.. I mean I get "Test A: OK" as output, but cant get
the SomeClass.class reference when I
look into the debugger.
Is this the right way to compare clases? if not, whats the right way?
(Im trying to not do == "SomeClass")
Felipe Piccolini M.
felipe.piccolini(a)bluesoft.cl
17 years, 5 months
assertObject gone
by Jean Safar
Hi,
I download 4.0.0.MR3 and the examples do not compile anymore. In essence and
surprisingly, they try to call assertObject on a stateful session but this
method is nowhere to be found anymore.
Regards,
Jean Safar
17 years, 5 months
Is this syntax correct?
by Shai Bentin
I need to fire a rule if I have more then one fact that has an endDate property from the last 24 months... is the follwoing correct?
rule "testing123"
when
olList: ArrayList(size > 1) from collect(CreditEventLocal(creditEventTypeVlId == "SOMETHING", $endDate: endDate -> ($endDate.after(DateUtils.addMonthsFromToday(-24)))))
then
System.out.println("eurika");
end
Anyhow, if it is then I get a NullPointerException which doesn't tell me what the problem is. It happens in building time of course:
I'm using drools4.0.0MR2
Exception in thread "main" java.lang.NullPointerException
at org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:53)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:65)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:353)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:233)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:157)
at com.emi.framework.antTasks.PackageRules.addPackages(PackageRules.java:227)
at com.emi.framework.antTasks.PackageRules.execute(PackageRules.java:143)
at com.emi.framework.antTasks.PackageRules.main(PackageRules.java:325)
17 years, 5 months
The effect of not using shadow facts
by Chris West
Hello,
With prior versions of JBoss Rules (3.0.5) I have been using JDK generated
dynamic proxies as facts, and they have been working fine. However, after
upgrading to JBoss Rules 4.0.0MR3, I cannot seem to get the dynamic proxies
to work as facts. It seems that even though a rule fires that changes a
field on the proxy, a second rule that should not be activated after the
update still fires.
According to the JDK javadoc documentation, dynamic proxies are created as
final. My assumption is that JBoss Rules is not creating Shadow facts for
these since they are final. After reading the JIRA at
http://jira.jboss.com/jira/browse/JBRULES-960, I now am questioning what the
effect of not using shadow facts is on the engine. The relevant part of
that is:
"The problem is that SpringAOP is generating a proxy whose methods equals()
and hashCode() are "final". As drools must either override these methods in
the shadow proxy or not shadow the fact at all, I'm disabling shadow proxy
generation for this use case.
It is really important to note that if you are asserting SpringAOP proxies
as facts into the working memory, you will not be able to change any field
value whose field is constrained in rules or you may incur in a memory leak
and non-deterministic behavior by the rules engine. Unfortunately there is
nothing we can do about, since when SpringAOP makes the methods equals and
hashcode final, we can't override them anymore and as so, we can't shadow
them."
[ Show » <http://jira.jboss.com/jira/browse/JBRULES-960> ]
Edson Tirelli<http://jira.jboss.com/jira/secure/ViewProfile.jspa?name=tirelli>
[02/Jul/07 03:29 PM] The problem is that SpringAOP is generating a proxy
whose methods equals() and hashCode() are "final". As drools must either
override these methods in the shadow proxy or not shadow the fact at all,
I'm disabling shadow proxy generation for this use case. It is really
important to note that if you are asserting SpringAOP proxies as facts into
the working memory, you will not be able to change any field value whose
field is constrained in rules or you may incur in a memory leak and
non-deterministic behavior by the rules engine. Unfortunately there is
nothing we can do about, since when SpringAOP makes the methods equals and
hashcode final, we can't override them anymore and as so, we can't shadow
them.
Although I'm not using SpringAOP, I believe my facts are not being
shadowed.
Is it true that not using shadow facts may lead to non-deterministic
behavior? Prior to shadow facts, the engine seemed to handle it. Any
chance of reverting back to the old style of truth maintenance in the case
of not using shadow facts.
I apologize if I'm not on the right track here. My only test case for my
problem is the entire application right now, so I cannot offer it for
discussion. Any advice would be greatly appreciated.
Thanks,
-Chris West
17 years, 5 months