[rules-users] What may go in the Action when dialect is java
Kris Verlaenen
kris.verlaenen at cs.kuleuven.be
Thu Aug 27 09:37:33 EDT 2009
Have you defined the imports for all your classes (including the helper
class)? And defined your global and variable correctly?
I tried something similar with a simple process as pasted below, and
that seems to working.
Might want to check for any differences ...
Kris
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process
drools-processes-5.0.xsd"
type="RuleFlow" name="ruleflow" id="com.sample.ruleflow"
package-name="com.sample" >
<header>
<imports>
<import name="com.test.Campaign" />
<import name="com.test.CampaignHelper" />
<import name="com.test.CampaignInfo" />
</imports>
<globals>
<global identifier="result" type="com.test.CampaignResult" />
</globals>
<variables>
<variable name="msg" >
<type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="com.test.jpa.Message" />
</variable>
</variables>
</header>
<nodes>
<actionNode id="2" name="Hello" x="96" y="16" width="80" height="48" >
<action type="expression" dialect="java" >Campaign c =
msg.getCampaign();
CampaignInfo info = CampaignHelper.getCampaignInfo(c);
result.setCampaignInfo(info);</action>
</actionNode>
<start id="1" name="Start" x="16" y="16" width="48" height="48" />
<end id="3" name="End" x="208" y="16" width="48" height="48" />
</nodes>
<connections>
<connection from="1" to="2" />
<connection from="2" to="3" />
</connections>
</process>
Quoting jsk at orwtech.dk:
> Hi
>
> For some time I have been struggling to complete my Drools workflow
> without succes.
>
> I am trying to access static methods on som java classes but for
> some
> reason i keep getting NoSuchMethodException when switching the
> dialect
> from "mvel" to "java" to be able to call this methods.
>
> What I have at runtime is a message variable containing a campaign
> class
> instance which I want to parse on to my static method for it to
> return an
> campaign information class instance to me.
>
> Which I then set in a global variable that I read outside the
> knowledge
> session.
>
> The global variable is defined like this:
>
> global com.test.CampaignResult result
>
> The flow variable is defined like this:
>
> com.test.jpa.Message msg;
>
> My code lookes like this:
>
> Campaign c = msg.getCampaign();
> CampaignInfo info = CampaignHelper.getCampaignInfo(c);
> result.setCampaignInfo(info);
>
> My Drools is 5.0.1
>
> Can anybody help me on getting this to work?
>
> Best regards
>
> Jesper
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the rules-users
mailing list