我正在使用eclipse进行开发,并且我已将包包含在构建路径中,但我仍然收到此错误。
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: ch/ethz/ssh2/Connection
Push_Individual_Engine.putFile(Push_Individual_Engine.java:107)
Push_Individual_Engine.doPost(Push_Individual_Engine.java:80)
Push_Individual_Engine.doGet(Push_Individual_Engine.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.ClassNotFoundException: ch.ethz.ssh2.Connection
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1493)
Push_Individual_Engine.putFile(Push_Individual_Engine.java:107)
Push_Individual_Engine.doPost(Push_Individual_Engine.java:80)
Push_Individual_Engine.doGet(Push_Individual_Engine.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.30 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.30
这是我正在使用的代码,
private void putFile(File f){
Connection Conn = null;
try {
Conn = new Connection("servername");
ConnectionInfo info = Conn.connect();
Conn.authenticateWithPassword("username" , "password");
SCPClient SCP = new SCPClient(Conn);
SCP.put(f.toString(), "foldername", "0755");
Conn.close();
} catch (Exception e) {
try {
Conn.close();
} catch (Exception e1) {}
}
}
任何想法?
答案 0 :(得分:1)
需要将相关的jar文件(包含无法找到的类的文件)放在webapp的WEB-INF/lib
目录中。仅将其添加到构建路径是不够的。