File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes problem using commons-fileupload lib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem using commons-fileupload lib" Watch "problem using commons-fileupload lib" New topic

problem using commons-fileupload lib

Dave Robbins
Ranch Hand

Joined: Sep 16, 2003
Posts: 131
Hello All,

I'm trying to use the commons-fileupload lib from the jakarta project
I'm using Netbeans 3.6 as a development environment.
I thought I just put the jar file in the lib directory of my project and start using it, that's all I had to do with other libs
When I do that, and import org.apache.commons.filedownload into my servlet, I'm able to take the first step in using, create a FileUpload object. I can compile it fine. When I execute it it throws a

java.lang.NoClassDefFoundError: javax/servlet/ServletInputStream

it happens in the constructor of FileUpload
I downloaded the source code so I could try to debug the problem.
Wasn't quite sure how to use the source code so I just threw the jar file out and incorporated the file download source code into the classes directory of my project and used it that way.
Now it works fine (in the development environment)
So I cary on and figure out how to do what I want to do and get it all working.
I bundle whole thing up in a war file and try to deploy it onto a a real tomcat server.
It throws the same exception

java.lang.NoClassDefFoundError: javax/servlet/ServletInputStream

It throws this not when I try to run it but during deployment.
I search all the source code for file upload package and see no reference to ServletInputStream
What gives??
Any ideas??

Vrushank Joshi

Joined: Oct 24, 2004
Posts: 11
Hii Dave Robbins,

Do one thing, Just extract your JAR file. and after that try to execute your code. I think this might be helpful to u.
Dave Robbins
Ranch Hand

Joined: Sep 16, 2003
Posts: 131
hmm, how strange
Last night I figured out that I can deploy my app (using the manager application which is part of tomcat) on a different machine and everything works fine. This morning I took your suggestion and stopped tomcat on the machine where I'm having trouble, copied the war file into the webapps dir, and restarted tomcat. It deployed properly and everything is fine.
So it looks like the problem is not my app but something with the manager application in tomcat. It's a new installation of tomcat and it's the first time I've set it up from scratch in a while, maybe I better go read the docs and see if I missed something. I thought all I had to do was unzip the package and add myself to tomcat-user.xml.

Anyway, thanx for the help!
I agree. Here's the link:
subject: problem using commons-fileupload lib
It's not a secret anymore!