动态网络项目:"java.lang.ClassNotFoundException"尽管WEB-INF/lib目录中有.jar文件 [英] dynamic web project: "java.lang.ClassNotFoundException" despite .jar file in the WEB-INF/lib directory

查看:84
本文介绍了动态网络项目:"java.lang.ClassNotFoundException"尽管WEB-INF/lib目录中有.jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个需要一些.jar文件的作业.作业需要我对带有JSP文件的Tomcat servlet进行一些工作.

I'm working on an assignment that requires some .jar files. The assignment requires me to do some work on a Tomcat servlet with JSP files.

我将.jars包含在Eclipse的Java Build Path中,然后将它们复制/添加到WEB-INF/lib目录中.

I included my .jars in the Java Build Path in Eclipse, and copied/added them to the WEB-INF/lib directory.

当我像这样运行项目时:http://localhost:8080/project/我看到index.jsp页上有空div,其中数据应该来自通过TestServlet.java执行的代码.

When I run the project like so: http://localhost:8080/project/ I see the index.jsp page with empty divs where data should be from the code executed via the TestServlet.java.

寻找原因,签出http://localhost:8080/project/TestServlet时看到以下错误:

Looking for the reason why, I see the following error when I check out http://localhost:8080/project/TestServlet:

May 3, 2013 1:22:26 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [TestServlet] in context with path [/project] threw exception [Servlet execution threw an exception]
with root cause java.lang.ClassNotFoundException: com.aetrion.flickr.FlickrException

    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
    at TestServlet.doGet(TestServlet.java:27)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)

这很奇怪,因为我再次在Java Build Path中包含了.jars,并将.jars复制/添加到了WEB-INF/lib目录.

Which is weird, since, again, I included the .jars in the Java Build Path and copied/added the .jars to the WEB-INF/lib directory.

有什么想法或帮助吗?

推荐答案

请确保首先将jar放在web-inf/lib中,然后将其添加到t 项目>构建路径>配置构建路径>按此顺序添加jar,对吗?

just to be sure, first you put the jar in the web-inf/lib and after you add it in t project > build path > configure build path > add jar , in that order , correct?

尝试在库"标签中将罐子移到顶部或几乎顶部...这将是可见性问题

try in the "libraries" tab moving the jar at the top or almost the top... would be a problem of visibility

这篇关于动态网络项目:"java.lang.ClassNotFoundException"尽管WEB-INF/lib目录中有.jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆