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
Inserting Facts from Json Format
by ihabo01
Hello to all,
I have the following simple rule:
declare FlatData
param1 : String
param2 : String
end
rule "Test"
when
a:FlatData(param1=="something")
then
a.setParam2("hi");
end
And I have the following code to load the rule:
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add(ResourceFactory.newFileResource("myRule.drl"),ResourceType.DRL);
KnowledgeBaseConfiguration kBaseConfig = KnowledgeBaseFactory
.newKnowledgeBaseConfiguration();
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(kBaseConfig);
kBase.addKnowledgePackages(kBuilder.getKnowledgePackages());
StatefulKnowledgeSession session = kBase.newStatefulKnowledgeSession();
session.fireAllRules();
And I have also the following object (in Json) that I would like to insert
as a fact just before firing the rules:
{"object":{" FlatData ":{"param1":"value1","param2":”value2”}}}}
How can I achieve that?
Many thanks in advance for your help
Ihab
--
View this message in context: http://drools.46999.n3.nabble.com/Inserting-Facts-from-Json-Format-tp3570...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Drools verifier
by FrankVhh
Hi all,
Triggered by a post on this forum, I decided to try a testcase
implementation of Drool Verifiier.
I manage to write some code that does not produce any errors at runtime,
which is good. Unfortunately, it doesn't produce any errors/warnings/notes
on my rulefile either, which isn't good.
The drl file consists of some duplicate rules, and since the file is only
part of a ruleset, there might be some gaps as well.
I pasted the java-code below. Does anyone see where I am going wrong?
Thanks in advance!
Regards,
Frank
VerifierBuilder vBuilder =
VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
String ruleText =
"C:\\Users\\Frank\\Documents\\DroolsWorkSpaces\\EmpiricalExperiments\\Financial
Rules\\src\\main\\rules\\clearancerules.drl";
verifier.addResourcesToVerify( ResourceFactory.newReaderResource(
new StringReader( ruleText ) ), ResourceType.DRL );
verifier.fireAnalysis();
VerifierReport result = verifier.getResult();
for(VerifierMessageBase base: result.getBySeverity(
Severity.ERROR ) ){
System.out.println( base );
}
for(VerifierMessageBase base: result.getBySeverity(
Severity.WARNING ) ){
System.out.println( base );
}
for(VerifierMessageBase base: result.getBySeverity( Severity.NOTE )
){
System.out.println( base );
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-verifier-tp268...
Sent from the Drools - User mailing list archive at Nabble.com.
12 years, 5 months
Challenge! Using javassist and drools presents an issue with drl
by markricard
In order to make writing drl files easy and not requiring writers to be
developers, I have written some JavaAssist code that dynamically creates a
subclass and new methods in memory.
If for example there is a REAL java class called 'com.foo.Instance'. Via
javasssist, I create a new in-memory subclass called 'com.foo.InstanceEx'.
The new class dynamically creates a new getter called getFoo(). The drl
writer would like to directly reference 'foo' in the drl file like so:
when
i : Instance(foo == 'fee')
The problem is, in order to reference foo, I would need the drl file to do
this:
import com.rrd.xspace.drools.InstanceEx;
But I cannot do that because InstanceEx does not exist at runtime. The
error I get, which is an obvious one, is "Unable to create Field Extractor
for 'foo' of '[ClassObjectType class=com.foo.Instance]' in rule 'Test' :
[Rule name='Test']"
Is there a way to include a dynamic import of a JavaAssist class while I am
constructing the KnowledgeBase instances to run the rules so that I can
reference that new method?
I would hope to have something similar to:
KnowledgeBuilder kbuilder = ....
kbuilder.addImport("com.foo.InstanceEx")
or
kbuilder.addClass(Class.forName("com.foo.InstanceEx"))
Any help GREATLY appreciated.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Challenge-Using-javas...
Sent from the Drools - User mailing list archive at Nabble.com.
12 years, 6 months
Why is solving a partial puzzle much slower than generating one from scratch?
by aitchnyu
I am making a 3x3 Sudoku solver with Drools planner. The planning entities
are the digits. The problem facts are the rows (planning variable) and
columns.
When I set Drools Planner to solve a problem where no digit is initialized,
it gives a perfect solution in ~15 secs. But when I set a few digits as
initialized, it never finds a solution. It always lists 8 hard constraints
broken on termination.
I implemented the moves as:
if(digit.getFixed()==false){
moveList.add(new RowChangeMove(digit, toRow));
}
If the digit is fixed, dont make a move object for it.
Earlier, I implemented it in isMoveDoable: if the digit.getFixed() is true,
it returns false. Both do not work.
20:31:13.442 [main] INFO o.d.p.c.l.DefaultLocalSearchSolverPhase - Phase
local search finished: step total (978), time spend (60061), best score
(-8).
20:31:13.442 [main] INFO o.d.p.core.solver.DefaultSolver - Solved: time
spend (60061), best score (-8), average calculate count per second (7433).
--
View this message in context: http://drools.46999.n3.nabble.com/Why-is-solving-a-partial-puzzle-much-sl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
Guvnor data enumeration issue
by GPatel@tsys.com
I am trying to use data enumerations and running into a problem. Following
the Vehicle engineType/fuelType data enumeration example in the Guvnor
manual, I created the following enumeration list and it works:
'Vehicle.engineType' : (new test.VehicleHelper()).getEngineTypes()
'Vehicle.fuelType[engineType]' : '(new
test.VehicleHelper()).getFuelTypes("@{engineType}")'
VehicleHelper:
------------
public class VehicleHelper {
public List<String> getEngineTypes(){
List<String> engineTypes = new ArrayList<String>();
engineTypes.add("Petrol");
engineTypes.add("Diesel");
return engineTypes;
}
public List<String> getFuelTypes(String engineType){
List<String> fuelTypes = new ArrayList<String>();
if("Petrol".equalsIgnoreCase(engineType)){
fuelTypes.add("ULP");
fuelTypes.add("PULP");
}
else if("Diesel".equalsIgnoreCase(engineType)){
fuelTypes.add("BIO");
fuelTypes.add("NORMAL");
}
else{
fuelTypes.add("Default Fuel 1");
fuelTypes.add("Default Fuel 2");
}
return fuelTypes;
}
}
Above works as expected.
Problem:
I want to only have an enumeration on Vehicle.fuelType that depends on the
value of engineType, without specifying an enumeration on engineType. So,
I took out the first line in my enumeration list so that it is now:
'Vehicle.fuelType[engineType]' : '(new
test.VehicleHelper()).getFuelTypes("@{engineType}")'
But that does not work. When I create a rule, VehicleHelper.getFuelTypes
does not get called and the dropdown for fuelType is not a list.
How do I get this working?
Thanks
G. Patel
-----------------------------------------
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you
12 years, 6 months