Servlet运行时错误:想知道可能是什么原因?

时间:2015-01-25 11:25:19

标签: json eclipse java-ee servlets web-applications

servlet中的代码导致运行时出错。

JSONArray parent = new JSONArray();

    int total=0;
    int count=1;
    int seatswon=0;


    while(rs.next()){
        count++;
        if(count>4){
            seatswon = rs.getInt(2);
            total += seatswon;          
        }
        else{
        JSONObject child = new JSONObject();
        seatswon = rs.getInt(2);
        String partyname=rs.getString(1);
        //System.out.println(partyname+"-"+ seatswon);
        total += seatswon;
        child.put("seatswon", seatswon);
        child.put("partyname", partyname);          
        parent.put(child);
        }

    }

    //total += total_others;
    DB.closeDB();
    JSONObject child = new JSONObject();
    child.put("seatswon", total);
    child.put("partyname","Total");

    parent.put(child);
    pw.print(parent);

    //System.out.println(parent.toString());
    pw.close();
    }catch(Exception e){e.printStackTrace();}

SEVERE:带有路径[/ Proect1]的上下文中servlet [getLevel]的Servlet.service()引发异常[Servlet执行引发异常]的根本原因 java.lang.ClassNotFoundException:org.json.JSONArray     在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)     在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)     在api.akasalabs.nation.getNatLevel.doGet(getNatLevel.java:52)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:620)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:727)     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)     在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)     在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)     在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)     在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)     在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)     在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)     在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)     在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)     在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)     at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:611)     at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:314)     在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)     at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     在java.lang.Thread.run(Thread.java:722)

1 个答案:

答案 0 :(得分:0)

包含类org.json.JSONArray的jar不在webapp的WEB-INF/lib目录中。所以Tomcat找不到这个类。