【问题标题】:how to resolve java.lang.ClassNotFoundException: Acme.JPM.Encoders.GifEncoder?如何解决 java.lang.ClassNotFoundException: Acme.JPM.Encoders.GifEncoder?
【发布时间】:2018-07-31 13:20:44
【问题描述】:

我正在研究一个简单的示例,我只是使用 servlet 显示图像:

public class ImageServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    response.setContentType("image/gif");  
    ServletOutputStream out = response.getOutputStream();  
    //Optain image icon
    ImageIcon icon = new ImageIcon("inbox/apple.gif");
    Image image = icon.getImage();
    new GifEncoder(image, out, true).encode();

    out.close();
}
} 

错误:

type Exception report
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.NoClassDefFoundError: Acme/JPM/Encoders/GifEncoder
imageChecker.ImageServlet.doPost(ImageServlet.java:30)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

如何解决这个错误我将 acme.jar 放在构建路径中 在此先感谢

【问题讨论】:

    标签: java apache servlets classnotfoundexception imageicon


    【解决方案1】:

    在阅读了一些关于 servlet 的博客后,我找到了解决方案

    Just put acme.jar and all other jar file inside the WebContent ->WEB-INF ->lib directory 并构建项目我直到现在才知道为什么构建路径 jar 文件在这种情况下不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-23
      • 1970-01-01
      • 2020-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多