0

我正在使用一个库,其结构如下

在此处输入图像描述

我正在将vn.hus.nlp.tokenizer-4.1.1.jar文件添加到库中,Add JAR/Folder并将其余部分复制到我的项目中。当我使用java应用程序时它工作。但是当我尝试 servlet 时,我在使用这个库时遇到了问题。

我的项目

在此处输入图像描述

Servlet:类Filter扩展 HttpServlet

try {          
       VietTokenizer v = new VietTokenizer(); // error here !
       JSONObject jso=new JSONObject();
       jso.put("status","A");
       jso.put("label","true");
       out.print(jso);
    } finally {            
        out.close();
    }

日志

SEVERE: Servlet.service() for servlet [Filter] in context with path [/BadwordFilter] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.commons.cli.ParseException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
    at badword.filter.Filter.processRequest(Filter.java:51)
    at badword.filter.Filter.doGet(Filter.java:74)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

json-simple-1.1.1.jar is work well. 谢谢你!

4

2 回答 2

1

我认为,当您部署时,库不会在库中导入右键单击您的 Web 项目,选择Libraries。在Complie选项卡中,确保您的库已被选中!

于 2013-10-01T15:13:09.390 回答
1

你错过了commons-cli图书馆。例如,您可以在此处找到它,包含在 lib 文件夹的存档中:

https://code.google.com/p/vntagger-gate-plugin/source/browse/lib/vn.hus.nlp.tokenizer-4.1.1.jar

您可以像添加第一个库一样添加它。

于 2013-10-01T09:43:40.337 回答