java - 错误 java.lang.ClassNotFoundException

标签 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 中,但它仍然不起作用。我不知道为什么?有什么办法可以解决这个问题吗? 非常感谢。

最佳答案

不是eclipse缺少库,而是tomcat缺少库。确保您的部署已将 org.openl.rules-5.16.2.jar 放入 Web 应用程序的 WEB-INF/lib 中。

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

关于java - 错误 java.lang.ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34173506/

相关文章:

java - Tomcat 启动时未找到 SSL 配置 : getting class(PureTLSImplementation, JSSE15Factory)

java - 在java矩阵工具包(MTJ)中创建行 vector

java - 仅让类的一部分等待执行,无论是否有线程?

java - 如何从 servlet 访问 www 目录中的文件?

java - 将日期作为参数从 JSP 发送到 servlet

java - 尽管类在类路径中,但 ClassNotFoundException

java - 如何解决 ClassNotFoundException?

java - junit 等待外部资源准备好

java - 将数组的内容添加到 JFrame、添加 JPanel、添加 JScroll

java - 从 valueUnbound(HttpSessionBindingEvent event) 方法修改 ServletContext 的属性