<html><body><div><div>Okay Wolfgang ... you asked for it. Here's a version which takes it pretty much to the minimum.</div><div><br></div><div>The error I see is "Unable to resolve method using strict-mode: mypackage.CloneMessage.cloneMessage(mypackage.Message)"</div><div><br></div><div>However, the error is only seen when I use mvel dialect. The working Java dialect rule is also included below.</div><div><br></div><div>Note that when I re-wrote the example function to take a common type such as String as argument, then the mvel version worked. It's when the argument is a declared type that it fails.</div><div><br></div><div>Thanks for taking a look,</div><div><br></div><div>Steve</div><div><br></div><div><br></div><div><strong><br></strong></div><div><strong>file - MessageFact.drl</strong></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; package mypackage</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; declare Message</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; Text: String</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; end</span></div><div><br></div><div><br></div><div><br></div><div><strong>file - CloneMessage.drl</strong></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; package mypackage</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; function Message cloneMessage(Message originalMessage) {</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; Message newMessage = new Message();</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; newMessage.setText(originalMessage.getText());</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; return newMessage;</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; }</span></div><div><br></div><div><br></div><div><br></div><div><strong>file - SayHelloRuleJava.drl</strong></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; package mypackage</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; rule "Say hello"</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; dialect "java"</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; lock-on-active true</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; when</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Always</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; then</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Message originalMessage = new Message();</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; originalMessage.setText("Hello, World!");</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Message clonedMessage = cloneMessage(originalMessage);</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert(clonedMessage);</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; end</span></div><div><br></div><div><br></div><div><br></div><div><strong>file - SayHelloRuleMvel.drl</strong></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; package mypackage</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; rule "Say hello"</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; dialect "mvel"</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; lock-on-active true</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; when</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Always</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; then</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Message originalMessage = new Message();</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; originalMessage.Text = "Hello, World!";</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Message clonedMessage = cloneMessage(originalMessage);</span></div><div><br></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert(clonedMessage);</span></div><div><span style="font-family: 'courier new', monospace; ">&nbsp; &nbsp; end</span></div></div><div><br></div><div><br></div><div><br>On Jun 19, 2012, at 12:27 PM, Wolfgang Laun &lt;wolfgang.laun@gmail.com&gt; wrote:<br><br></div><div><blockquote type="cite"><div class="msg-quote"><div class="_stretch">Can you please provide an example where and how you import and use a<br> DRL function so that it works/doesn't work with MVEL/Java?<br> <br> -W<br> <br> <br> On 19/06/2012, Stephen Masters &lt;<a href="mailto:stephen.masters@me.com" data-mce-href="mailto:stephen.masters@me.com">stephen.masters@me.com</a>&gt; wrote:<br> &gt; Hi folks,<br> &gt;<br> &gt; Is it possible to refer to DRL functions from a DRL when the dialect is<br> &gt; mvel?<br> &gt;<br> &gt; I have been working on unit tests for a rule that were consistently failing<br> &gt; due to not being able to find the function that should be imported. Having<br> &gt; tried various formats (the documentation is rather unhelpful here) for the<br> &gt; import, I thought I'd see what happened if I just switched to the Java<br> &gt; dialect. Suddenly it worked without even needing an import statement.<br> &gt;<br> &gt; Unfortunately, this forces me to switch from the neat ...<br> &gt; newFact.Property = otherFact.Property<br> &gt; ... to the rather ugly Java-style<br> &gt; newFact.setProperty(otherFact.getProperty())<br> &gt;<br> &gt; So I would quite like to know if there is an undocumented (or<br> &gt; well-hidden-documented) mechanism for using functions when in mvel dialect.<br> &gt; Or am I stuck with switching to Java?<br> &gt;<br> &gt; Thanks in advance for any pointers anybody can provide,<br> &gt;<br> &gt; Steve<br> _______________________________________________<br> rules-users mailing list<br> <a href="mailto:rules-users@lists.jboss.org" data-mce-href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" data-mce-href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></div></div></blockquote></div></body></html>