9

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: Project Settings

And here's the run configuration: enter image description here

Trouble started when I added FileUpload.
Any idea what's wrong?

Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
  • Wait, did you ever change the buildpath/classpath after dropping JARs in `/WEB-INF/lib`? You should **not** do that! Just dropping the JARs ought to be sufficient. – BalusC Aug 06 '11 at 04:41
  • @BalusC you're right, I was adding specific JARs when I should have pointed to the directory as a whole. Thanks. – Amir Rachum Aug 06 '11 at 11:35
  • No, even not that! When you create a "Dynamic Web Project" in Eclipse, it will take all automagically and rightly into account. You just have to drop the dependency JAR(s) in `/WEB-INF/lib` folder. Nothing else needs to be done. No fiddling in project's properties or something. – BalusC Aug 06 '11 at 13:35

2 Answers2

4

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.

Kal
  • 24,724
  • 7
  • 65
  • 65
0

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.

highlycaffeinated
  • 19,729
  • 9
  • 60
  • 91