NPE loading Drools 5.4.0.Beta1 using drools-spring
by lhorton
I am trying to load up 5.4.0.Beta1. I'm using Spring configuration xml that
works fine in 5.2.0.Final. In the xml, my grid-node is defined as:
<drools:grid-node id="droolsClusterNode1"/>
The exception is a NPE on a method in WhitePagesClient. Any idea what the
cause might be? Has anyone successfully loaded 5.4.0 using Spring?
The full exception is:
ERROR 2012-01-06 15:51:05,998
[org.springframework.web.context.ContextLoader] - Context initialization
failed
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'droolsClusterNode1': Invocation of init method failed; nested
exception is java.lang.NullPointerException
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1399)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at
org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
at
org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:252)
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(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
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:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:291)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at
org.drools.grid.service.directory.impl.WhitePagesClient.getGsd(WhitePagesClient.java:32)
at
org.drools.grid.service.directory.impl.WhitePagesClient.create(WhitePagesClient.java:80)
at org.drools.grid.impl.GridImpl.createGridNode(GridImpl.java:107)
at
org.drools.container.spring.beans.GridNodeBeanFactory.afterPropertiesSet(GridNodeBeanFactory.java:63)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 47 more
--
View this message in context: http://drools.46999.n3.nabble.com/NPE-loading-Drools-5-4-0-Beta1-using-dr...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 4 months
Eclipse, Groovy and Drools - java.lang.NoClassDefFoundError
by sweeneymj
Hi,
I have just started trying out Drools and having an issue trying to run the
sample applications under Eclipse Helios with Groovy installed.
When I try run any sample Drools application I get the stack trace shown
below. I have looked around extensively on Google for assistance but have
been unable to find any thing that has helped me determine what the issue
is.
Any suggestions would be appreciated.
Regards
--
Build groovy files option has not been set one way or the other: use
'options.put(CompilerOptions.OPTIONG_BuildGroovyFiles,
CompilerOptions.ENABLED);'
java.lang.NoClassDefFoundError: org/eclipse/core/runtime/Plugin
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at
org.eclipse.jdt.internal.compiler.Compiler.initializeParser(Compiler.java:737)
at
org.eclipse.jdt.internal.compiler.Compiler.<init>(Compiler.java:294)
at
org.eclipse.jdt.internal.compiler.Compiler.<init>(Compiler.java:159)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:364)
at
org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51)
at
org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:366)
at
org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:55)
at
org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:69)
at
org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:674)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:633)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:278)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:451)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:40)
at com.sample.DroolsTest.main(DroolsTest.java:23)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.Plugin
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 27 more
--
View this message in context: http://drools.46999.n3.nabble.com/Eclipse-Groovy-and-Drools-java-lang-NoC...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
Apply role to whole class hierarchy
by Joerg Henne
Hi all,
we are processing events through a Fusion rule base. To be recognized as
such, model classes must be declared as @role(event). We are using a rather
extensive hierarchy of events, all derived from a single abstract class.
Unfortunately, it doesn't seem to be possible to declare just this base
class as an event and have the 'event' role for the others derived from
that.
Is there a way around having to declare each and every single event class
separately?
Thanks
Joerg
--
View this message in context: http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
fire a rule only once (for the time being)
by slyfox
It seems like there are many similar problems but I have not been able to
find anything that addresses my issue exactly.
I have a stock trading application, and I want to check if the price is out
of a range (high,low)
if the price goes below low, the problem is the rule keeps firing if the
price keeps going lower, this creates too much noise and overhead.
I thought maybe the no-loop and duration attributes would help but they
didnt.
I know I could check not(Fired()) and use insert fired but I believe that
spans the entire session which I do not want either.
Is there a way to say fire this rule if true once then wait a period of time
before I check again.
>From what Ive read maybe agenda filters, but I am not sure if that is
flexible enough.
--
View this message in context: http://drools.46999.n3.nabble.com/fire-a-rule-only-once-for-the-time-bein...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
How to iterate over a given rule multiple times
by RulesUsers
Hi All,
I have a specific requirement where in, i have my rules file as follows
rule "one"
when
//some condition
then
//fire a particular query & retrieve the count of records for a filter
condition
//Then populate it to some fact property using modify()
end
rule "two"
when
//check if the count of records is, say 100 after, the above modify
statement
then
//any further action
end
Now the problem is, I want to execute rule "one" again and again until rule
"two" is satisfied.
Two probable solutions I can think of is: -
1. Put some condition in rule "one", so that rule"one" is true until rule
"two" condition is satisfied. But that has a problem, rule"one" will still
fire even if rule "two" gets satisfied.
2. Other is, have some kind of third rule that will call rule "one",
when rule"two" is not satisfied.
Please provide your valuable inputs.
Thanks in advance.
Regards,
Sam
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-iterate-over-a-given-rule-multip...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
Using global variable in DRL file
by zeeshan
Hi All !
I am trying use global variable in DRL file but when I am using it, gives
Exception. Please have a look at the DRL file -----
package com.drools.rules
import com.drools.facts.*;
*global CSVBeanAgent csvAgent;* [here I have declared the Global variable]
rule "Calculating Agent APE"
salience 35
no-loop true
when
$csvPolicy : CSVBeanPolicy()
//$csvAgent : CSVBeanAgent()
then
System.out.println("For agent --->zzzzz in rule setting premium form
rate>>>>"+$csvPolicy.getPremiumMode());
double policyAPE=$csvPolicy.getPolicyAPE();
System.out.println("policyAPE>>>>>"+policyAPE);
*System.out.println("Agent
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz>>>>>"+csvAgent);*
double agentAPE=0.0;
if(csvAgent.getAgentNo()==$csvPolicy.getAgentNo()){
System.out.println("inside if");
agentAPE=agentAPE+policyAPE;
}
csvAgent.setAgentAPE(agentAPE);
System.out.println("AgentAPE>>>>>>>>>>>>>>>"+csvAgent.getAgentAPE());
update($csvPolicy);
end
Above is my rule....the Bold one is I am trying to the value of *csvAgent*,
it gives *null* value. Please help me in finding the solution i.e. How to
declare the global variable and how to use it in DRL file.
Thanks !
--
View this message in context: http://drools.46999.n3.nabble.com/Using-global-variable-in-DRL-file-tp401...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
Collections versus Relational Approach in Fact Model
by BenjaminWolfe
I'm learning Java and Drools at the same time; please be gentle if my
question is misdirected.
I'm working on creating my first nontrivial fact model. A policy can have
multiple vehicles; a vehicle can have multiple coverages. My data will come
into the rules engine via an XML file, and be output to XML after all rules
are fired. I'm looking for best practices.
I've seen it suggested to use a relational approach to my object graph. A
policy will have policyID 12345; its vehicles will have a policyID field,
and each will have a different vehicleNumber (e.g. 1, 2 and 3). A coverage
will have policyID (12345) and vehicleNumber(1), and a coverage identifier
of its own.
That seems simple, sleek and elegant. I hope to use it to write rules. But
I wonder if it will be resource-intensive when I get to outputting the XML.
I'm imagining having to write the policy node, then search all vehicles for
the 3 that are related to this policy, then search through all coverages for
the ones corresponding to each vehicle, etc.
Is it better to include some sort of collection? (Policy 12345 might
include a collection of vehicles, each of which would include a collection
of coverages.) If so, what kind of collection: an implementation of set?
list? map? More specifically, are there drawbacks or advantages to one
approach or another?
I'm very thankful for any guidance you'd like to offer.
Best regards,
Benjamin
--
View this message in context: http://drools.46999.n3.nabble.com/Collections-versus-Relational-Approach-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months
Counting events / fact condition not evalauted with accumulate
by jpullmann
Dear contributors,
this simple rule should trigger only when a critical amount of particular
events was detected,
though it seems to accept any event of this type, disregarding the fact
condition (e.g. there
is no single event that matches "target == Long.MAX_VALUE"). The current
behaviour results in
an unconstrained type match: LocalizationEvent():
// annotation for external event class
declare LocalizationEvent
@role( event )
@duration( dur )
@timestamp( time )
end
// triggers on *any* LocalizationEvent, regardless of fact condition
rule "Detect crictial number of events"
when
accumulate(
// there is no matching event
$ev: LocalizationEvent(type == TYPE.LEFT, target == Long.MAX_VALUE, area
== Long.MAX_VALUE)
over window:time(30s) from entry-point "events/localization";
$n : count( $ev );
$n > 5 )
then
System.out.println($n+" events detected" );
end
The KB is configured for stream processing, the events are inserted in a
chronological order
and the session pseudo clock is advanced accordingly. Drools version in
use is 5.4.0.
Any suggestions are appreciated!
Many thanks
Jaro
--
View this message in context: http://drools.46999.n3.nabble.com/Counting-events-fact-condition-not-eval...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months