Hi Russell,

>From looking at the examples I think your fix should be just a matter of
changing your function definition from:

public void printStock

to

public static void printStock


cheers
Steve


On 3/8/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Guys:
>
> I am working through a simple example for loading rules.  I am running jdk
> 1.5, eclipse 3.1.1, and drools2.5 final.
>
>     When I run the application it complains about the rules.  This is the
> rule set
>
>    <?xml version="1.0" encoding="UTF-8"?>
> <rule-set name="BusinessRuleSample"
>    xmlns="http://drools.org/rules";
>    xmlns:java="http://drools.org/semantics/java";
>    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance";
>          xs:schemaLocation="http://drools.org/rules rules.xsd
>                             http://drools.org/semantics/java java.xsd">
>
> <!-- Import the Java Obje ts thate are referenced in the rules -->
> <java:import>java.lang.Object</java:import>
> <java:import>java.lang.String</java:import>
> <java:import>com.company.dept.product.domain.StockOffer</java:import>
>
> <!-- A Java utility function we reference in the rules -->
>   <java:functions>
>     public void printStock(com.company.dept.product.domain.StockOfferstock){
>        System.out.println("Name:"     + stock.getStockName()
>                           + " Price:" + stock.getStockPrice()
>                           + " BUY:"   + stock.getRecommendPurchase());
>     }
>   </java:functions>
>
>   <rule name="Stock Price Low Enough">
>       <!-- parameters to pass to business rule -->
>      <parameter identifier="stockOffer">
>         <class>StockOffer</class>
>      </parameter>
>      <!--  Conditions or 'left hand side' (LHS) that must be met
>            for business rule to fire-->
>      <java:condition>stockOffer.getRecommendPurchase() == null
> </java:condition>
>      <java:condition>stockOffer.getStockPrice() &lt; 100 </java:condition>
>      <java:consequence>
>               stockOffer.setRecommendPurchase(StockOffer.YES);
>               printStock(stockOffer);
>      </java:consequence>
>   </rule>
> </rule-set>
>
>   I am getting this error:
> [start of error]
> org.drools.semantics.java.JavaSemanticCompileError: A problem occured
> compiling the embedded code:
>
> drools/org/businessrulesample_1141764314250/java/Stock_Price_Low_Enough_0.java(30)
> Cannot make a static reference to the non-static method
> printStock(StockOffer) from the type Function_0_0
> [end of error]
>
> Any insight would be greatly appreciated.....
>
> Russ
>
>
>


--
Steven Williams

Supervising Consultant

Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
[EMAIL PROTECTED]
www.objectconsulting.com.au

consulting | development | training | support
our experience makes the difference

Reply via email to