错误java.lang.ClassNotFoundException

时间:2015-12-09 07:57:31

标签: java servlets classnotfoundexception

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;
}

当我调用ActionRule方法时,Eclipse会给出错误消息: Error

我将org.openl.rules-5.16.2.jar添加到了Libraies中,但它仍然无效。我不知道为什么?有谁有解决这个问题的解决方案? 非常感谢。

1 个答案:

答案 0 :(得分:1)

不是因为缺少图书馆的日食,而是它的tomcat。确保您的部署已org.openl.rules-5.16.2.jar放入您的网络应用的WEB-INF/lib

之后,重新启动tomcat或重新部署您的应用