类型异常报告 消息 Servlet 执行抛出异常 描述 服务器遇到一个内部错误,阻止它完成这个请求。 例外 javax.servlet.ServletException:Servlet 执行引发异常 根本原因 java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException java.lang.ClassLoader.defineClass1(本机方法) java.lang.ClassLoader.defineClassCond(未知来源) java.lang.ClassLoader.defineClass(未知来源) java.security.SecureClassLoader.defineClass(未知来源) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) Hello.doGet(Hello.java:42) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 根本原因 java.lang.ClassNotFoundException:org.apache.commons.lang.exception.NestableRuntimeException org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) java.lang.ClassLoader.defineClass1(本机方法) java.lang.ClassLoader.defineClassCond(未知来源) java.lang.ClassLoader.defineClass(未知来源) java.security.SecureClassLoader.defineClass(未知来源) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) Hello.doGet(Hello.java:42) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note Apache Tomcat/7.0.33 日志中提供了根本原因的完整堆栈跟踪。
和我的编码在这里
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.sql.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* Servlet implementation class Getting_data
*/
public class Hello extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Hello() {
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
Connection con;
Statement stmt;
ResultSet rs = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:Emp_info");
stmt = con.createStatement();
String query = "select * from Emp_table";// where employee_name='"+emp_name+"' or department='"+emp_dept+"' or email='"+email+"' order by employee_name";
System.out.println("query " + query);
rs = stmt.executeQuery(query);
pw.println("Id"+"Name"+"Address"+"<br>");
JSONArray arrayObj=new JSONArray();
JSONArray arrayObj1=new JSONArray();
JSONObject responseData = new JSONObject();
while(rs.next())
{
//pw.println(rs.getString(1) + " " + rs.getString(2) + "<br>");
String name = rs.getString(1);
String name1 = rs.getString(2);
arrayObj.add(new String(name));
arrayObj1.add(new String(name1));
}
responseData.put("rows", arrayObj);
responseData.put("data", arrayObj);
pw.print(responseData);
}
catch (Exception e){
pw.println(e);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}