[rules-users] JBoss AS 4.0.5 GA + Drools 4.0.1
Guardian
d.h.j. at gmx.de
Mon Sep 24 09:23:09 EDT 2007
Hello,
I have many problems to integrate Drools in my existing Application that is
running on JBoss AS 4.0.5 GA.
When I try to load and execute the rule-file I get the following Exception:
java.lang.RuntimeException: java.lang.NoSuchMethodError:
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclip
se/jdt/core/compiler/CategorizedProblem;
javax.ejb.EJBException: java.lang.RuntimeException:
java.lang.NoSuchMethodError:
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclip
se/jdt/core/compiler/CategorizedProblem;
at
org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:10
1)
at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationIntercepto
r.java:76)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:10
1)
at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstan
ceInterceptor.java:62)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:10
1)
at
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationIn
terceptor.java:77)
at
org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3Authenticat
ionInterceptor.java:102)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:10
1)
at
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.ja
va:47)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:10
1)
at
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInter
ceptor.java:106)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:10
1)
at
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer
.java:263)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingIn
vocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThr
ead.java:358)
at
org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412
)
My Application consists of the following parts:
The rule-file:
#created on: 04.09.2007
package drools.rules
#list any import classes here.
import drools.session.Message;
#declare any global variables here
rule "Hello World"
when
m : Message( status == Message.HELLO, message : message )
then
System.out.println( message );
m.setMessage( "Goodbye cruel world" );
m.setStatus( Message.GOODBYE );
update( m );
end
rule "GoodBye"
no-loop true
when
m : Message( status == Message.GOODBYE, message : message )
then
System.out.println( message );
m.setMessage( message );
end
a Class to encapsulate the rule-initialisation and rule-execution
(wrapper-Class):
public class RuleEngineWrapper
{
private WorkingMemory workingMemory;
private boolean debugMode = false;
private DebugAgendaEventListener debugListener;
public RuleEngineWrapper(WorkingMemory wm) {
this.workingMemory = wm;
debugListener = new DebugAgendaEventListener();
}
/**
* construct a RuleEngineWrapper with only a rule-file-name, no idea
of
* callers' class. Assume the rule file is located
*
* @param rulesFile
*/
public RuleEngineWrapper(String rulesFile) {
this(RuleEngineWrapper.class, rulesFile);
}
/**
* construct a RuleEngineWrapper with only a calling object known
*
* @param caller
* @param rulesFile
*/
public RuleEngineWrapper(Object caller, String rulesFile) {
this(caller.getClass(), rulesFile);
}
/**
* construct a RuleEngineWrapper with Class caller and
rule-file-name known.
* We load the rule-file as classpath resource.
*
* @param caller
* @param rulesFile
*/
public RuleEngineWrapper(Class caller, String rulesFile) {
super();
try {
final PackageBuilder builder = new PackageBuilder();
System.out.println(caller);
builder.addPackageFromDrl(new InputStreamReader(caller
.getResourceAsStream(rulesFile)));
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
workingMemory = ruleBase.newStatefulSession();
debugListener = new DebugAgendaEventListener();
} catch (Exception e) {
System.out.println("cannot read rule file: " + rulesFile);
}
}
/**
* Allow to add arbitrary objects as facts. Users can add any
objects to
* workingMemory
*
* @param o
* the fact to be added
*/
public void addFact(Object o) {
workingMemory.insert(o);
}
/**
* Execute rules.
*
*/
public void executeRules() {
workingMemory.fireAllRules();
}
/**
* toggle debugging mode (adds a DebugAgendaEventListener if called
once.
* Removes if called again.
*/
public void setDebugMode( boolean debug ) {
if (debugMode ) {
workingMemory.removeEventListener( debugListener );
}
else workingMemory.addEventListener(debugListener);
}
public WorkingMemory getWorkingMemory() {
return workingMemory;
}
public void setWorkingMemory(WorkingMemory workingMemory) {
this.workingMemory = workingMemory;
}
}
A stateless Sessionbean for the access from the Testcase
@Remote(droolsManagement.class)
public @Stateless class droolsManagementBean implements droolsManagement
{
public void startRuleEngineWrapper(String rulesFile, ArrayList<Object>
objektListe) throws Exception
{
try
{
//load up the rulebase + StatefulSession (WorkingMemory)
RuleEngineWrapper rew = new
RuleEngineWrapper("/drools/rules/" + rulesFile);
for (Object object : objektListe)
{
rew.addFact(object);
}
rew.executeRules();
}
catch (Exception e)
{
System.out.println("exception in
'droolsManagementBean.startRuleEngineWrapper(String, ArrayList<Object>)',
cannot handle it...");
}
}
}
And the test-case:
@Test
public void TestDroolsRuleEngineWrapper()
{
try
{
String rulesFile = "testRule.drl";
//go !
Message message = new Message();
message.setMessage( "Hello World" );
message.setStatus( Message.HELLO );
ArrayList<Object> objektListe = new ArrayList<Object>();
objektListe.add(message);
droolsM.startRuleEngineWrapper(rulesFile, objektListe);
}
catch (Exception e)
{
System.out.println("Exception in
TestDroolsRegeln.TestDroolsRuleEngineWrapper: " + e.getMessage());
e.printStackTrace();
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070924/01c749d1/attachment.html
More information about the rules-users
mailing list