java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6964109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
提问by Amir Rachum
I get the following error:
我收到以下错误:
06/08/2011 02:56:33 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet UploadTheme threw exception
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
at org.apache.commons.fileupload.servlet.ServletRequestContext.getContentType(ServletRequestContext.java:73)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:905)
at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:351)
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
at cs236369.hw5.servlets.xml.UploadTheme.doPost(UploadTheme.java:47)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
I place JARS under WEB-INF/lib
. Here's what the project classpath looks like:
我将 JARS 放在WEB-INF/lib
. 这是项目类路径的样子:
And here's the run configuration:
这是运行配置:
Trouble started when I added FileUpload.
Any idea what's wrong?
当我添加 FileUpload 时,问题就开始了。
知道出了什么问题吗?
采纳答案by Kal
You don't need the commons-upload jar files in the server's run configuration. I suspect that this is the reason for this problem, because there is some visibility of classes issue between the classloader that loaded the file-upload class and the one trying to load the servlet specific classes.
您不需要服务器运行配置中的 commons-upload jar 文件。我怀疑这就是这个问题的原因,因为在加载文件上传类的类加载器和尝试加载 servlet 特定类的类加载器之间存在一些类问题的可见性。
You should get rid of it and leave it as part of the WEB-INF/lib. Hopefully that fixes your problem.
您应该摆脱它并将其作为 WEB-INF/lib 的一部分。希望这能解决您的问题。
回答by highlycaffeinated
Looks to me like j2ee.jar
/javaee.jar
isn't on your classpath. You need to download it and put it in your $CATALINA_HOME/lib
directory.
在我看来j2ee.jar
/javaee.jar
不在您的类路径中。您需要下载它并将其放入您的$CATALINA_HOME/lib
目录中。