开发者

java.lang.NoClassDefFoundError when using Apache FileUpload

I am using Apache FileUpload and I am getting a java.lang.NoClassDefFoundError

My first thought was to check whether the .jar was on the classpath - what I notice (in Eclipse) is that under the libraries area, there are two different sections:

  • Apache Tomcat v6.0
  • Web App Libraries

All the other libraries are listed under "Web App Libraries" and this particular library is listed under Apache Tomcat v6.0

I am assuming this is causing the problem ... my code is here below ... but I think it's a config issue rather than a code issue.

Finally - the web.xml is not the problem as I have taken out the FileUpload stuff from the servlet and the servlet gets found just fine.

public c开发者_JS百科lass SaveImage extends HttpServlet{

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
    System.out.println("Got here");
    response.setContentType("text/html;charset=UTF-8");
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
}


This has to be a classpath issue. What your IDE thinks is on the classpath is not as important as what the web server thinks is on the classpath. What's in the WEB-INF/lib folder after your app is deployed (in the deployment target directory)? That's what the real classpath is (plus the web server's libs, of course).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜