开发者

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest [duplicate]

This question already has answers here: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest (7 answers) Closed 7 years ago.

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(StandardHostValv开发者_JAVA技巧e.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:

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest [duplicate]

And here's the run configuration:

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest [duplicate]

Trouble started when I added FileUpload.

Any idea what's wrong?


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.

You should get rid of it and leave it as part of the WEB-INF/lib. Hopefully that fixes your problem.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜