Slf4j Log4j logger not working with Drools drl while using as a global variable.
by Soumya.plavaga
I am using global slf4j log4j logger as a global variable within our drl and
inserting that global logger value at runtime into kiesession. While we are
trying to do logger.info with multiple arguments then it's giving the
following exception stack trace -
Exception executing consequence for rule "Test Logger 2" in
test.rules.system: java.lang.RuntimeException: cannot invoke method: info
at
org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at
org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1027)
at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:129)
at
org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:71)
at
org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:935)
at
org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1200)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:952)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:926)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:232)
at
test.platform.rules.executor.service.impl.RuleExecutorServiceImplTest.testExecuteRule(RuleExecutorServiceImplTest.java:230)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at
org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at
org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at
org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at
org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at
org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: cannot invoke method: info
at
org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:63)
at
org.mvel2.optimizers.impl.refl.nodes.VariableAccessor.getValue(VariableAccessor.java:37)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
at
org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
at org.mvel2.MVEL.executeExpression(MVEL.java:930)
at
org.drools.core.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:107)
at
org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1016)
... 36 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at
org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.executeAll(MethodAccessor.java:140)
at
org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:48)
... 44 more
Example: My drl file looks like this -
package test.system.rule;
import test.platform.model.*;
import org.slf4j.Logger;
global Logger logger;
rule "Test Logger 1"
when
then
logger.info("within test logger 1");
end
rule "Test Logger 2"
when
then
logger.info("within test logger 2. Rule fired {}",
drools.getRule().getName());
end
While rules are firing then the first logger is getting printed into console
but second one is not getting printed and giving the above exception to me.
--
View this message in context: http://drools.46999.n3.nabble.com/Slf4j-Log4j-logger-not-working-with-Dro...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 4 months
How to read XML using XMLPackageReader-Drools-compiler.5.2.1.final?
by Praveen
Hi,
I am using Drools-compiler.5.2.1.final.
I am trying to convert an drl to xml and vice versa using DrlParser,
DrlDumper, XMLPackageReader and XML Dumper.
Drl to XML conversion works fine but XML to Drl throws NPE.
I have placed the XML file under a folder called sample.
NPE is thrown at line 5..
Also attached is the exception.
Please suggest.
TIA.
Reader source = new InputStreamReader(
DroolsConversionHelper.class.getResourceAsStream(xmlFileName));
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
XmlPackageReader reader = new
XmlPackageReader(conf.getSemanticModules());
DrlDumper dumper = new DrlDumper();
//line 5 reader.read(source);
PackageDescr descr = reader.getPackageDescr();
String test = dumper.dump(descr);
System.out.println(test);
java.lang.NullPointerException
at
org.drools.xml.ExtensibleXmlParser.resolveSchema(ExtensibleXmlParser.java:696)
at
org.drools.xml.ExtensibleXmlParser.resolveEntity(ExtensibleXmlParser.java:622)
at
com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEntity(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.resolveDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
Source)
Regards,
Praveen.
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-read-XML-using-XMLPackageReader-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
KieContainer#updateToVersion fails when both versions of a drl file contain an event type declaration for an existing class
by mikedev9000
I am using the latest drools 6.1.0-SNAPSHOT. I have two jars containing
different versions of a KieModule, and they each contain a drl file with an
event type declaration for an existing class. If I try to update the
container from one version to the other, the call to
KieContainer#updateToVersion returns a Results instance that contains errors
related to the @timestamp attribute on that event declaration. Here is an
example of the error message: "[Message [id=1, level=ERROR, path=r0.drl,
line=3, column=0
text=Error creating field accessors for timestamp field 'mytime' for type
'FooEvent']]".
The following .patch file can be used to add a unit test to the
IncrementalCompilationTest.java file that demonstrates this problem.
test_container_update_problem.patch
<http://drools.46999.n3.nabble.com/file/n4030100/test_container_update_pro...>
After applying the patch, and running this unit test, I see the following
test failure:
java.lang.AssertionError: Errors detected on updateToVersion: [Message
[id=1, level=ERROR, path=r0.drl, line=3, column=0
text=Error creating field accessors for timestamp field 'mytime' for type
'FooEvent']]
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertFalse(Assert.java:64)
at
org.drools.compiler.integrationtests.IncrementalCompilationTest.testUpdateWithDeclarationPresent(IncrementalCompilationTest.java:95)
This error makes it nearly impossible for me to rely on and use
KieContainer#updateToVersion, because I need to allow frequent changes to be
made to drl files at run time, and I would prefer not to recreate the
KieContainer, and all of its KieBases and KieSessions on every update.
Is this a known issue? If so, are there plans to fix it before the
6.1.0.Final release?
--
View this message in context: http://drools.46999.n3.nabble.com/KieContainer-updateToVersion-fails-when...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
kie-drools-wb-6.0.1 : view "artifact repository" is empty
by jps
Hello,
The artifact repository view in drools-wb is suddenly empty :( after having
uploaded a new jar. Before this operation, I had 3 artifacts that were
listed ..
I try to redeploy the app, restart jboss, delete JBOSS_HOME/bin/repository
and start again ... but still the list of artifact in the repository is
empty, although i can see it's not empty on the disk in
JBOSS_HOME/bin/repository/kie/...
Something has been corrupted somewhere. But I'm stuck. Any idea or
suggestions ?
What can prevent drools-wb from getting the repo data ?
Thanks
jps
--
View this message in context: http://drools.46999.n3.nabble.com/kie-drools-wb-6-0-1-view-artifact-repos...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
Equality semantics of logical assertions and stated assertions
by mikerod
I understand that logical insertions in Drools does not insert two facts that
are equal according to their #equals implementation (and associated
#hashCode logic).
I'm basing this off of my own investigation plus the (well written)
documentation @
http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html/....
However, normal/stated fact assertions only use identity-based equality
checks - by default.
It looks like this can be changed to value-based equality via
RuleBaseConfiguration.
I have found some related, old Jiras:
https://issues.jboss.org/browse/JBRULES-266
https://issues.jboss.org/browse/JBRULES-233
In both cases, Mark Proctor had a final remark, but I wasn't able to
understand what was really decided and why.
One specific comment @ https://issues.jboss.org/browse/JBRULES-266 is,
"logical assertions are always equality based. Stated facts can now use
identity and equality - using your configuration settings.
I have added another configuration setting to dictate how logical over-ride
works. Does it discard the original fact, or turn it into two stated fact
handles."
What is the reasoning behind only using the value-based equality for logical
assertions?
Why is it not configurable as stated fact assertions are?
Also, why is the default behavior of stated fact assertion to be
identity-based equality?
- I find the inconsistency between the default for normal assertions and the
(only option) for logical assertion to be a bit confusing/inconsistent.
I'm just looking for an understanding the motivation behind these design
decisions.
I have had a lot of performance issues using, primarily, logical assertions
due to the "no duplicate" checking being done.
Even the stated assertions do still come with a cost of creating the initial
FactHandle.
With deeply nested/complex domain objects, the #equals and #hashCode
implementations may be quite expensive when executed many times throughout
rule execution.
This is especially prominent in accumulators that may later accumulate these
objects into collections that then are also subject to this equals/hashCode
"penalty".
I have a related post a while back @
http://drools.46999.n3.nabble.com/Object-size-impact-on-session-insertion....
I do not believe it is typical to use complex domain model objects as the
keys to something like a HashMap.
One reason (there are more; especially for mutable objects) would be due to
the performance around having them be hashed and equality checked regularly
when the
map is accessed, modified, etc.
The creation of many FactHandle's has shown up in some of my profiling
performance problems due to this the constructor immediately hashing my
domain model objects.
I think the reason the fact handles use this information is for value-based
equality comparisons - such as the only method used by the Truth Maintenance
System logical assertions.
I would really appreciate more insight into the motivation for not allowing
#equals facts to be logically asserted separately into working memory -
especially since there is a price to pay for the behavior in my case.
--
View this message in context: http://drools.46999.n3.nabble.com/Equality-semantics-of-logical-assertion...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
Rules not picked when packaged inside the JAR
by ash316
I am working on DROOLS 6.0.1 application. I have my rule files (*.drl)
packaged inside a separate project which is included as a jar file as a
maven dependency. When I deploy my project, KIEModule is not able to find
the rules files (which are packaged inside the jar above). I am not getting
an error though but rules are not getting fired.If I manually place the
rules files under classpath say WEB-INF/rules/*.drl they are detected and
rules are executed.I was under impression that KIEmodules are auto
discovered from anywhere in classpath.Any pointers are appreciated. This is
general question hence I have not included the comprehensive code files.
Everything start working once I place the *.drl files in the classpath (take
them outside of jar).I have opened the JIRA issue @ Link
<https://issues.jboss.org/browse/DROOLS-466> Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Rules-not-picked-when-packaged-inside-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
kbase using kie
by Chris B
I am using 6.0.1 and having difficulties in kmodule.xml.
My goal is to have a directory where I can keep putting new rules which
should be automatically picked up.
But looks like drools is looking in the jar file for new rules.
What should be my entries.
My current kmodule.xml
###################
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="rules" packages="DRL" eventProcessingMode="stream">
<ksession name="ksession-rules"/>
</kbase>
</kmodule>
My pom.properties
####################
#Generated by Maven
#Wed Jun 25 17:53:00 PDT 2014
version=0.0.1
groupId=com.myc
artifactId=MyProject
The output which I am getting
#####################
2014-06-29 16:45:08 o.d.c.k.b.i.ClasspathKieProject [INFO] Found kmodule:
jar:file:/home/chrism/apache-storm-0.9.1-incubating/lib/MyProject-0.0.1.jar!/META-INF/kmodule.xml
2014-06-29 16:45:08 o.d.c.k.b.i.ClasspathKieProject [DEBUG] KieModule URL
type=jar
url=/home/chrism/apache-storm-0.9.1-incubating/lib/MyProject-0.0.1.jar
2014-06-29 16:45:08 o.d.c.k.b.i.ClasspathKieProject [DEBUG] Found and used
pom.properties META-INF/maven/com.myc/MyProject/pom.properties
2014-06-29 16:45:08 o.d.c.k.b.i.ClasspathKieProject [DEBUG] Discovered
classpath module com.myc:MyProject:0.0.1
2014-06-29 16:45:09 o.d.c.k.b.i.KieRepositoryImpl [INFO] KieModule was
added:ZipKieModule[
ReleaseId=com.myc:MyProject:0.0.1file=/home/chrism/apache-storm-0.9.1-incubating/lib/MyProject-0.0.1.jar]
2014-06-29 16:45:09 o.d.c.k.b.i.ClasspathKieProject [INFO] Found kmodule:
jar:file:/home/chrism/apache-storm-0.9.1-incubating/lib/MyProject-0.0.1.jar!/META-INF/kmodule.xml
2014-06-29 16:45:09 o.d.c.k.b.i.ClasspathKieProject [DEBUG] KieModule URL
type=jar
url=/home/chrism/apache-storm-0.9.1-incubating/lib/MyProject-0.0.1.jar
2014-06-29 16:45:09 o.d.c.k.b.i.ClasspathKieProject [DEBUG] Found and used
pom.properties META-INF/maven/com.myc/MyProject/pom.properties
2014-06-29 16:45:09 o.d.c.k.b.i.ClasspathKieProject [DEBUG] Discovered
classpath module com.myc:MyProject:0.0.1
2014-06-29 16:45:09 o.d.c.k.b.i.KieRepositoryImpl [INFO] KieModule was
added:ZipKieModule[
ReleaseId=com.myc:MyProject:0.0.1file=/home/chrism/apache-storm-0.9.1-incubating/lib/MyProject-0.0.1.jar]
2014-06-29 16:45:09 o.d.c.k.b.i.AbstractKieModule [WARN] No files found for
KieBase rules
----------------------------
As above it is not able to read the rules as the rules are located in the
filesystem somewhere else like in /a/b/c directory and it is in the
classpath, but not being read as it seems to be only looking in jar file
Any help greatly appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/kbase-using-kie-tp4030187.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months