using matches in a collection
by ygaurav
Hi All
i am new to drools and I am hoping that some body can help me out here.
I data in string array and I would like to check if one of the entry starts
with the string I have. How can check it ?
Code is shown below
@java
class ABC {
String[] array = new String[]{"abcdef","ghijkl","mnopqrst"}
}
@drools
rule "check something"
when
$abc : ( ABC.array contains a single entry which start with "abc" )
Is there a way I can do it ? If it is not possible what is way I can achive
it
Thanks
--
View this message in context: http://www.nabble.com/using-matches-in-a-collection-tp18115893p18115893.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
Backward chaining in drools 5?
by Alberto Cabas Vidani
I read the information available about drools 5, but support to backward
chaining is never mentioned. Since in the documentation of Drools 4 it's
said that it will be supported in the next major release I'm wondering
wether it will be present in release 5. Does anyone know something about it?
Alberto
15 years, 7 months
ClassCastException when firing rules
by seemamani
hi,
We are using Drools 4.0.7 in a web application deployed in WebSphere 6.1.
Occasionally, we have rule engine failure caused by RuntimeDroolsException
(whose root cause is shown as ClassCastException) when firing rules. Other
times, the rules are executing without errors. Here is the stack trace of
the exception. What are the possible reasons?
Thanks,
Seema
org.drools.RuntimeDroolsException: Exception executing predicate eval(
inventory.leaseInformation != null )
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:216)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:911)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
at
com.adesa.business.framework.rules.process.drools.ManagedStatefulSession.init(ManagedStatefulSession.java:87)
at
com.adesa.business.framework.rules.process.drools.ManagedStatefulSession.fireAllRules(ManagedStatefulSession.java:100)
at
com.adesa.business.framework.rules.process.drools.RuleEngineImpl.execute(RuleEngineImpl.java:60)
at
com.adesa.business.framework.rules.interceptor.RulesInterceptor.applyAnnotedRules(RulesInterceptor.java:109)
at
com.adesa.business.framework.rules.interceptor.RulesInterceptor.applyRules(RulesInterceptor.java:80)
at sun.reflect.GeneratedMethodAccessor575.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:597)
at
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:583)
at
org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:60)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
at
com.adesa.business.rules.RuleHandler$$EnhancerByCGLIB$$3ab6eda.fireUpdatePricing(<generated>)
at
com.adesa.business.auction.manager.SaleEventManagerImpl.updatePricing(SaleEventManagerImpl.java:2599)
at
com.adesa.business.auction.manager.SaleEventManagerImpl.cascadeAtEndOfAuction(SaleEventManagerImpl.java:1993)
at
com.adesa.business.auction.manager.SaleEventManagerImpl.cascadeAtEndOfGroundingSaleEventForHyundai(SaleEventManagerImpl.java:1783)
at
com.adesa.business.auction.manager.SaleEventManagerImpl.cascadeAtEndOfGroundingSaleEvent(SaleEventManagerImpl.java:1180)
at
com.adesa.business.auction.manager.SaleEventManagerImpl.cascadeAtEndOfGroundingSaleEvent(SaleEventManagerImpl.java:1134)
at
com.adesa.business.auction.service.AuctionServiceImpl.cascadeAtEndOfGroundingSaleEvent(AuctionServiceImpl.java:766)
at sun.reflect.GeneratedMethodAccessor263.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
at
com.adesa.business.framework.logging.LoggingInterceptor.profileLog(LoggingInterceptor.java:136)
at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:597)
at
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:583)
at
org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:60)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:54)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:54)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy58.cascadeAtEndOfGroundingSaleEvent(Unknown Source)
at
com.adesa.business.pricing.ejb.PricingBean.updateMBPPrice(PricingBean.java:112)
at
com.adesa.business.pricing.ejb.EJSRemoteStatelessPricing_a0966b04.updateMBPPrice(EJSRemoteStatelessPricing_a0966b04.java:183)
at
com.adesa.business.pricing.ejb._EJSRemoteStatelessPricing_a0966b04_Tie.updateMBPPrice(_EJSRemoteStatelessPricing_a0966b04_Tie.java:243)
at
com.adesa.business.pricing.ejb._EJSRemoteStatelessPricing_a0966b04_Tie._invoke(_EJSRemoteStatelessPricing_a0966b04_Tie.java:108)
at
com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:621)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:474)
at com.ibm.rmi.iiop.ORB.process(ORB.java:503)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1571)
at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2701)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2575)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
Caused by:
java.lang.ClassCastException: com.adesa.data.grounding.pojo.Inventory
incompatible with
com.adesa.data.grounding.pojo.Inventory$$EnhancerByCGLIB$$de81aab3
at ASMAccessorImpl_11448003161226563261710.getValue(Unknown Source)
at
org.mvel.ast.VariableDeepPropertyNode.getReducedValueAccelerated(VariableDeepPropertyNode.java:22)
at
org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:21)
at
org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:21)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:235)
at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:45)
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:209)
--
View this message in context: http://www.nabble.com/ClassCastException-when-firing-rules-tp20694738p206...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 8 months
JBoss Rules as a Daemon Service
by Arjun Dhar
Hi,
I uploaded the JBoss Rules 4 WAR; I saw the repository options but no admin
console to run a service. Maybe I'm missing something?!?!
Q) Being under the cover of the JBoss server am sure there must be some
fascility to run this as a daemon service 'out of the box'! Right?? <--
Important
(posted this 3 days ago but it got lost somwhere; prob deleted the approval
mail; FYI not being impatient :o) but its important so would like to know)
Thanks!
15 years, 8 months
using BigDecimal in rules
by Marina
Hi,
I'm getting unexpected results when when using BigDecimal objects for matching in rules.
I'm generating DRL in my code, using freemaker.
I have a RuleEngineNumericFact object which has two attributes:
String propertyName
BigDecimal propertyValue
Below is an example of a rule where I try to match a RuleEngineNumericFact object based on the two attributes:
rule "aaa"
agenda-group "r1"
dialect "java"
when
(RuleEngineNumericFact( propertyName == "somename" , propertyValue == 10.8 ))
then
String ruleId = drools.getRule().getName();
firedRuleIDs.add(ruleId);
end
Then I create a new RuleEngineNumericFact object and set its propertyValue as following:
String stringValue = "10.8";
BigDecimal propertyValue = new BigDecimal(stringValue, new MathContext(10));
(I also tried to use default precision settings by creating the BigDecimal value as:
BigDecimal propertyValue = new BigDecimal(stringValue);
)
When I insert this fact into the rule engine - the rule does not get fired, so the fact does not match.
One note: if the values are integeres (like, propertyValue == 100) - the rule gets fired. So, it is only the floating point numbers that do not match.
I generate the DRL in my Java code, using freemaker, and I specify the
value that will be used in the rule for matching by calling toString()
method on a BigDecimal object that I get from my business code. The toString() representation ends up to be the "10.8" value (for example).
According to the BigDecimal documentation, marshalling from/to the same string representation shoudl still produce BigDecimal objects that will return TRUE from the equals() method when compared.
any ideas why this is not working here?
How does Drools compare values of objects like BigDecimal?
thanks,
Marina
15 years, 8 months
Localization in DSL
by Shigeaki Wakizaka
Hello.
I'd like to use Japanese in DSL.
Is it possible?
Do you have a plan to do the localize-thing with DSL and
brand-new BRMS?
Thanks in advance
Shige
15 years, 8 months
RuleAgent question
by J Michael Dean
Two questions. I am interested in using RuleAgent but with the file
or dir property rather than the URL. However, it is not clear to me
where the directories or files must actually be located. If I use
dir=/
then the DirectoryScanner is invoked and claims to have found some
number of files, but I have no idea WHERE it is scanning. If I add
anything like dir=/foo then I get an invalid directory exception.
If I try file=/foo.pkg then I get exception that this is invalid file.
Question 1 - is there an example somewhere that can help me understand
where I am going off the track? I am working Eclipse environment.
Question 2 - if using the BRMS and URL, can there be a backup dir,
file, or cache option that is in the classpath rather than a specific
directory? I would like to distribute an Eclipse application that has
a rule package deployed, but that overrides this with the URL if
available.
Thanks.
- Mike
15 years, 8 months
drools-solver -- logger error (slf4j binding)?
by Andrew Waterman
Hi,
I'm using the drools-solver.M5 build through Maven and have gotten the
following error while running my project:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for
further details.
I've checked my dependency graph, and drools-solver references the
sl4j-api, but no implementation. I checked the mvnrepository, and
there are several other slf4j related projects. What is the preferred
binding for JDK1.6?
best wishes,
Andrew
---------------------------------
Andrew Waterman
San Cristóbal de las Casas, Chiapas, Mexico
+52 1 967 107 5902
+1 510 342 5693
15 years, 8 months
Help on using Drools with embedded objects
by Divya Rajendranath
Hi,
I am planning to use Drools - JBoss Rules Engine. My requirement is to
disburse mails from my application to different groups based on various
criteria. I want to use Drools here.
My object structure is as follows:
class A{
String B = "";
B b;
C c;
}
Hence Obj A has embedded objects within it, and obj B and C further has
embedded objects.
class B {
String X;
Z z;
}
class Z{
String t;
String s;
}
The decision on sending the mails based on the fields in embedded objects of
A. I pass instance of A to Drools
Format of drl file:
package...;
import ..;
rule "Test"
when $a:A(B(Z(s == "testvalue")))
then
$a.setSomething();
update($a);
end
I wanted to know if this (accessing fields in embedded/child object) is
feasible with Drools.
I get an error saying "UNable to compile myfile.drl when i try to fo this.
Could some one look into this issue and let me know the reason for this ?
Thanks
-D
15 years, 9 months