...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/eclipse/jdt/core/compiler/CategorizedProblem;
javax.ejb.EJBException : java.lang.RuntimeException : java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/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:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke( TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext( MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62 )
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext( MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77 )
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102 )
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext( MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke( ENCPropagationInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext( MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke( AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext( MethodInvocation.java:101)
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(AOPRemotingInvocationHandler.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(ServerThread.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();
}
[Mensagem cortada]
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users