Marvin 框架在我的 Eclipse 项目中完美运行。按照自述文件,我已将整个 marvin 文件夹复制到项目根文件夹。都好。
现在,当在 Eclipse 中设置与动态 Web 项目相同的应用程序并尝试在 Eclipses tomcat 9 上运行它时,我收到 HTTP 状态 500 – java.lang.ClassNotFoundException 导致的内部服务器错误(请参阅下面的“错误 1”)。
看来,在动态 Web 项目中,jar 应该位于 WEB-INF/lib 中。将 marvin_1.5.5.jar 复制到 WEB-INF/lib 时,正确找到了 marvin.image.MarvinImage 类(错误 1 消失)。
但不幸的是,没有找到 Marvin 图像插件。我试图将整个 marvin 文件夹复制到 WEB-INF/lib - 没有用。我收到另一个 HTTP 状态 500 – java.lang.NullPointerException 的内部服务器错误(请参阅下面的“错误 2”)。我试图将其设置MarvinDefinitions.setImagePluginPath
为 myproject/WebContent/WEB-INF/lib/plugins/ - 没有用。我在控制台中遇到错误:java.nio.file.NoSuchFileException: \myproject\WebContent\WEB-INF\lib\plugins\org.marvinproject.image.transform.scale.jar.
-> 有谁知道如何在动态 Web 项目中正确实现 Marvin?
错误 1
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Servlet execution threw an exception
Beschreibung The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.NoClassDefFoundError: marvin/image/MarvinImage
controller.HomeController.doPost(HomeController.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.ClassNotFoundException: marvin.image.MarvinImage
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
controller.HomeController.doPost(HomeController.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
错误 2
HTTP Status 500 – Internal Server Error
Type Exception Report
Beschreibung The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
java.lang.NullPointerException
marvin.util.MarvinJarLoader.getClass(MarvinJarLoader.java:69)
marvin.util.MarvinJarLoader.getObject(MarvinJarLoader.java:51)
marvin.util.MarvinPluginLoader.loadPlugin(MarvinPluginLoader.java:55)
marvin.util.MarvinPluginLoader.loadImagePlugin(MarvinPluginLoader.java:37)
marvin.MarvinPluginCollection.checkAndLoadImagePlugin(MarvinPluginCollection.java:1225)
marvin.MarvinPluginCollection.scale(MarvinPluginCollection.java:956)
marvin.MarvinPluginCollection.scale(MarvinPluginCollection.java:973)
controller.HomeController.doPost(HomeController.java:60)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)