我创建了一个小的EXTJS应用程序,它试图通过servlet发送请求。servlet试图使用JSON进行响应,但我得到了一个JSON数组未找到异常:
日志中的异常信息:
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ItemMaintenance] in context with path
[/EXTTestServlet] threw exception [Servlet execution threw an exception] with root cause:
java.lang.NoClassDefFoundError: Could not initialize class net.sf.json.JSONArray
at com.as400samplecode.ItemMaintenance.doGet(ItemMaintenance.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2476)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2465)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
我知道每个人都会说“你需要将JSON JAR文件放在WEB-INF中”,但它已经在那里了,我也尝试添加了所需的JSON依赖项。我尝试了不同的版本,但没有成功。
我还遵循了这个教程: http://javaeesupportpatterns.blogspot.co.uk/2012/08/javalangnoclassdeffounderror-parent.html 来理解Java EE中类未找到异常可能发生的原因以及可能的解决方案。
有谁能指导我下一步该去哪里查找或建议为什么会出现这种情况?
谢谢