<br> Really? That is a surprise to me... we need to handle that...<br><br> Maybe you can open a JIRA for us?<br><br> Thanks,<br> Edson<br><br><div class="gmail_quote">2008/5/6 Alessandro Lazarotti <<a href="mailto:alessandro@siq.com.br">alessandro@siq.com.br</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks Michael, I simulate.. your rule fire with successful.<br>
<br>
I discovered the problem. The object in property (like Foo in your example), when null, it's not throws NullPointerException, but "org.mvel.PropertyAccessException: unable to resolve property".<br>
With that, I never imagined that the problem was nullPointer, but I thought about any access visibility (duh!).<br>
<br>
[]'s<br>
Alessandro<br>
<br>
<br>
<br>
Michael B. escreveu:<div><div></div><div class="Wj3C7c"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Okay, I wrote a test case around the following and it works fine so let me<br>
know if this isnt what you are working with...<br>
<br>
Foo Class<br>
<br>
public class Foo {<br>
private String m_name;<br>
public String getName()<br>
{<br>
return m_name; }<br>
public void setName(String nm)<br>
{<br>
m_name = nm;<br>
}<br>
<br>
}<br>
<br>
<br>
Bar Class<br>
<br>
public class Bar {<br>
private Foo m_foo;<br>
public Foo getFoo()<br>
{<br>
return m_foo;<br>
}<br>
public void setFoo(Foo f)<br>
{<br>
m_foo = f;<br>
}<br>
public String toString()<br>
{<br>
return "I have a foo with a name of " + m_foo.getName();<br>
}<br>
<br>
}<br>
<br>
DRL Rule<br>
<br>
rule "FooBar Rule"<br>
<br>
when<br>
$bar : Bar( <a href="http://foo.name" target="_blank">foo.name</a> != "Wrong" )<br>
then System.out.println("Test Successful - " + $bar.toString());<br>
<br>
end<br>
<br>
<br>
Junit Test Case<br>
<br>
public void testProperties() {<br>
try<br>
{<br>
final Reader source = new InputStreamReader(<br>
FooBarTest.class.getResourceAsStream( "FooBar.drl" ) );<br>
RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>
PackageBuilder builder = new PackageBuilder();<br>
builder.addPackageFromDrl(source);<br>
if ( builder.hasErrors() ) {<br>
System.out.println( builder.getErrors().toString() );<br>
throw new RuntimeException( "Unable to compile<br>
\"FooBar.drl\".");<br>
}<br>
//get the compiled package (which is serializable)<br>
final Package pkg = builder.getPackage();<br>
<br>
//add the package to a rulebase (deploy the rule package).<br>
ruleBase.addPackage( pkg );<br>
final StatefulSession session = ruleBase.newStatefulSession();<br>
Foo foo = new Foo();<br>
foo.setName("Test");<br>
Bar bar = new Bar();<br>
bar.setFoo(foo);<br>
session.insert(bar);<br>
session.fireAllRules(); }<br>
catch (Exception e)<br>
{<br>
System.out.println(e.getMessage());<br>
e.printStackTrace();<br>
fail(e.getMessage());<br>
}<br>
<br>
}<br>
<br>
<br>
<br>
<br>
<br>
</blockquote></div></div><div><div></div><div class="Wj3C7c">
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>