Hi,
I mean, I checked the global and it was set.
I'm attaching the code, that causes the problem (Java and DRL). You need
just to set a proper path to DRL file while setting file property in
Java file. I think, the global is set in proper way.
In DRL, depending which rule is commented/uncommented, the code works or
not.
Best regards,
Przemek
Jaroslaw Kijanowski pisze:
And did the stack trace change? Can you post more details (drl, java
src)?
Przemysław Różycki wrote:
> Yes, I did. This was the first thing I've checked.
>
> Best regards,
> Przemek
>
> Jaroslaw Kijanowski pisze:
>> Did you set the global on your session?
>>
>>
http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/index.h...
>>
>>
>> Cheers
>>
>> Przemysław Różycki wrote:
>>> Sorry for responsing myself, but I'm still working on it and found
>>> that when factSource is a fact, not global, the rule works very
>>> well. I mean, this rule works fine:
>>>
>>> rule "My Rule"
>>> when
>>> $factSrc : FactSource( )
>>> $fact : Fact( ) from
$factSrc.getSomeFacts("a","b","c")
>>> then
>>> // do something
>>> end
>>>
>>> so what's the difference between invocation on global object and
>>> invocation on fact object? Why the first one doesn't work and the
>>> second one works?
>>>
>>> Best regards,
>>> Przemek
>>>
>>>
>>> Przemysław Różycki pisze:
>>>> Hi,
>>>>
>>>> could I ask for some advice, please, how to use a parametrized
>>>> method call to get some data using 'from' element in LHS.
>>>>
>>>> To be more precise, I would like to do something like this:
>>>>
>>>> rule "My Rule"
>>>> when
>>>> $fact : Fact( ) from
factSource.getSomeFacts("a","b","c")
>>>> then
>>>> // do something
>>>> end
>>>>
>>>> where factSource is for example some global and
>>>> getSomeFacts(String,String,String) is a parametrized method that
>>>> returns some array of Fact objects.
>>>>
>>>> Unfortunately, when I try to launch the following rule I have an
>>>> error:
>>>>
>>>> Exception in thread "main" org.mvel.PropertyAccessException:
unable
>>>> to resolve property:
factSource.getSomeFacts("a","b","c")
>>>> at
>>>>
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:295)
>>>>
>>>> at
>>>>
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110)
>>>>
>>>> at
>>>>
org.mvel.ast.VariableDeepPropertyNode.getReducedValueAccelerated(VariableDeepPropertyNode.java:26)
>>>>
>>>> at
>>>>
org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:70)
>>>>
>>>> at
>>>>
org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:24)
>>>>
>>>> at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
>>>> at
>>>> org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
>>>> at org.mvel.MVEL.executeExpression(MVEL.java:252)
>>>> at
>>>>
org.drools.base.dataproviders.MVELDataProvider.getResults(MVELDataProvider.java:55)
>>>>
>>>> at org.drools.reteoo.FromNode.assertTuple(FromNode.java:68)
>>>> at
>>>>
org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55)
>>>>
>>>> at
>>>>
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
>>>>
>>>> at
>>>>
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
>>>>
>>>> at
>>>> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
>>>> at org.drools.reteoo.Rete.assertObject(Rete.java:175)
>>>> at
>>>> org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
>>>> at
>>>>
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:181)
>>>>
>>>> at
>>>>
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1312)
>>>>
>>>> at
>>>>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:915)
>>>>
>>>> at
>>>>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
>>>>
>>>> at
>>>>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
>>>>
>>>> at com.sample.DroolsTest6.main(DroolsTest6.java:29)
>>>> Caused by: java.lang.NullPointerException
>>>> at
>>>>
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:530)
>>>>
>>>> at
>>>>
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:261)
>>>>
>>>> ... 21 more
>>>>
>>>> Documentation says:
>>>>
>>>> "The from Conditional Element allows users to specify a source for
>>>> patterns to reason over. This allows the engine to reason over data
>>>> not in the Working Memory. This could be a sub-field on a bound
>>>> variable or the results of a method call."
>>>>
>>>> so I assume that it is possible to do what I want. If not, could I
>>>> ask for an advice of some workaround, please?
>>>>
>>>> Best regards,
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
#created on: 2009-01-13
package amg.gg.test.droolstest6
#list any import classes here.
import com.sample.DroolsTest6.Fact;
import org.example.myBean.MyBean;
import com.sample.DroolsTest6.FactSource;
#declare any global variables here
global FactSource factSource;
rule "pre rule"
salience 1100
when
eval(true)
then
System.out.println(factSource);
end
rule "My Rule 1"
salience 1000
when
$fact : Fact( ) from
factSource.getSomeFacts("a","b","c")
then
System.out.println(">>> My Rule 1");
System.out.println($fact);
end
/*
rule "My Rule 2"
when
$factSrc : FactSource( )
$fact : Fact( ) from $factSrc.getSomeFacts("a","b","c")
then
System.out.println(">>> My Rule 1");
System.out.println($fact);
end
*/