[rules-users] function call

hypnosat7 ablarbi at yahoo.fr
Wed Aug 29 04:46:49 EDT 2007


I try and change the dialect but it doesn't work

rule "Your First Rule"
	dialect "mvel"
	when
		
	then
		 
		drools.rule.dialect="java"
		System.out.println(drools.getRule().getDialect());
		System.out.println("ok"+func());
		
		
end

the package still invalid :
* (1,6) unable to resolve method using strict-mode:
java.lang.Object.func(...)
* (1,6) unable to resolve method using strict-mode:
java.lang.Object.func(...)



hypnosat7 wrote:
> 
> Hi,
> 
>   I have a simple rule :
> 
> function String isTrue() {
> 	return "true";
> }
> 
> rule "new rule"
> dialect "mvel"
> 	when
> 		eval(true)
> 	then
> 		System.out.println("passe"+isTrue());
> end
> 
> But it seems impossible to call function's :
> 
> org.mvel.PropertyAccessException: failed to access property:
> <<System.out.println("passe"+isTrue())>> in: null
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
> 	at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
> 	at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
> 	at org.mvel.MVEL.executeDebugger(MVEL.java:327)
> 	at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:43)
> 	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
> 	at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
> 	at
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
> 	at
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
> 	at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37)
> Caused by: org.mvel.PropertyAccessException: null pointer exception in
> property: isTrue()
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:143)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
> 	at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
> 	at
> org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20)
> 	at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
> 	at org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:421)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
> 	... 10 more
> Caused by: java.lang.NullPointerException
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:429)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
> 	... 17 more
> org.drools.spi.ConsequenceException: org.mvel.PropertyAccessException:
> failed to access property: <<System.out.println("passe"+isTrue())>> in:
> null
> 	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:549)
> 	at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
> 	at
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
> 	at
> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
> 	at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37)
> Caused by: org.mvel.PropertyAccessException: failed to access property:
> <<System.out.println("passe"+isTrue())>> in: null
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
> 	at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
> 	at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
> 	at org.mvel.MVEL.executeDebugger(MVEL.java:327)
> 	at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:43)
> 	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
> 	... 4 more
> Caused by: org.mvel.PropertyAccessException: null pointer exception in
> property: isTrue()
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:143)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
> 	at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
> 	at
> org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20)
> 	at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
> 	at org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:421)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
> 	... 10 more
> Caused by: java.lang.NullPointerException
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:429)
> 	at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
> 	... 17 more
> 

-- 
View this message in context: http://www.nabble.com/function-call-tf4346267.html#a12383032
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list