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.
12 years, 3 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.
12 years, 3 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.
12 years, 3 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.
12 years, 3 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.
12 years, 3 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.
12 years, 3 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.
12 years, 3 months
Re: [rules-users] Rule Templates
by FrankVhh
>The information that would help me is (using Eclipse or JBDS) can one edit,
It depends if you mean edit the templates or edit the data that you use to
populate it.
You can create a rule template in any text editor you like and, AFAIK, it
can have any extension you prefer. Convert it to an inputstream and use it
in the code as is documented.
Regarding the data source, you have multiple options to collect the data.
Editing this data depends a bit on the type you are using. I typically
convert xml objects to java objects and use (and, sometimes, abuse) them to
fill the template and "generate" rules.
>compile to drl
Compile to drl is done using the code as documented.
String drl = converter.compile( objs, templateStream );
You can do with the String whatever you like. use it to feed a
knowledgebuilder directly, or write it to a file.
>and test the rule templates
Again. This depends on what you mean. If test the rule templates means:
"check whether it generates a correct drl", than there are 2 things you can
do.
1) Manually check that the rules are as you expect them to be.
2) Verify that the drl compiles in a knowledgebuilder.
If "test" means, check whether my generated rules can construct a correct
decision, then you wikk have to set up a service/a method/ a unit test in
which you use the rules to create a knowledge base and which takes input
data to generate a certain output.
If you want, you can use guvnor to create test scenarios or implement a
testing tool by your own.
Regards,
Frank
mclovis wrote
>
> Frank,
> Thank you for your quick reply. I had previously read your suggested
> documentation and understand the basics of rule templates. The information
> that would help me is (using Eclipse or JBDS) can one edit, compile to drl
> and test the rule templates. The information in the article does not
> reflect these things and furthermore has a lists of file types for Drools
> that is not in current versions of IDEs (example: rules resource). If you
> have knowledge of the mechanics of these things (using even Ant or Maven
> to compile), it would be much appreciated.
>
> Thanks in advance,
>
> Mike
>
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p4018956.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months