1
import org.openl.rules.runtime.RulesEngineFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
// Action rule
public static String ActionRule(ClassRule classRule, String gender,
        String marialStatus) throws IOException {
    // TODO Auto-generated method stub
    // define the interface
    RulesEngineFactory<?> rulesFactory = new RulesEngineFactory<Object>("D:/GreetingCustomer.xlsx");
    Object rules = rulesFactory.newInstance();
    Class<?> clazz = rulesFactory.getInterfaceClass();

    // define params
    String Gender = gender;
    String MarialStatus = marialStatus;

    // define info of rule method

    int iNumOfParams = classRule.getListItem().size();
    // define param types
    Class[] paramClases = new Class[iNumOfParams];
    paramClases[0] = String.class;
    paramClases[1] = String.class;

    // set param value
    Object[] params = new Object[iNumOfParams];
    params[0] = Gender;
    params[1] = MarialStatus;

    String result = "";
    try {
        Method method = clazz.getMethod(classRule.getRuleName(),
                paramClases);
        System.out.println("* Executing OpenL rules...\n");
        // invoke method
        Object interestAmount = method.invoke(rules, params);
        if (interestAmount != null) {
            System.out.println("Siri Say: " + interestAmount);
            result = interestAmount.toString();
        } else {
            System.out.println("Wrong input value");
            result = "Wrong input value";
        }
    } catch (NoSuchMethodException e) {
    } catch (InvocationTargetException e) {
    } catch (IllegalAccessException e) {
    }
    return result;
}

When i call the ActionRule method Eclipse give me error messages: Error

I added org.openl.rules-5.16.2.jar into Libraies but it still dont work. I dont know why? What anyone have solution to solve this problem ? Thanks so much.

2
  • Post the exception stack trace, as code-formatted text, in your question. And please respect the Java naming conventions, and don't ignore exceptions. Commented Dec 9, 2015 at 8:01
  • Your server does not have the class org.openl.rules.runtime.RulesEngineFactory (in a jar)? Commented Dec 9, 2015 at 8:18

1 Answer 1

1

It's not eclipse that's missing the library, it's tomcat. Make sure your deployment has org.openl.rules-5.16.2.jar placed into WEB-INF/lib of your webapp.

Afterwards, restart tomcat or redeploy your app

Sign up to request clarification or add additional context in comments.

2 Comments

yeah! i added org.openl.rules-5.16.2.jar into WEB-INF/lib and it's worked. Thanks so much
Yes. I accepted the answer. Sorry about forget it :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.