Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

oreilly file upload servlet problem  RSS feed

 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've just finished Googling for answers, but have come up short. Several folks have had this same problem, but unfortunately, I could not find a solution.

In short, I'm using O'Reilly's file upload servlet, cos.jar. The problem is, when I instantiate the following object:

MultipartParser mp = new MultipartParser(request, 1024);

This is throwing a NoClassDefFoundError: /javax/servlet/ServletRequest

I believe it's something to do with my arrangement of .jar files.

I have been using several other servlets and have not had this problem.
I have placed the cos.jar in tomcat_home/common/lib - no success.

Does anyone have any ideas?

Thanks!
 
Vishal R Patel
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeffrey Hunter,

As per the signature in MultipartRequest, we have two options to use:

1. public MultipartRequest(ServletRequest request,
String saveDirectory,
int maxPostSize)
2. public MultipartRequest(ServletRequest request,
String saveDirectory)

But you are using
public MultipartRequest(ServletRequest request,
int maxPostSize)
which may be the cause of the error.

Try first in your program by giving saveDirectory destination as per your convinience or req.

Hope will work.

Vishal
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Vishal. I may have made a typo in my previous post -- I've used all the different constructors to no avail.

Anyhow, after brushing the dust of some archived posts from some other Ranchers, I may have stumbled onto the solution. Apparently, when the constructor was being called, the JVM was looking for a reference to ServletRequest, which resides in servlet.jar, in TOMCAT_HOME/common/lib. However, for some reason it was not finding it here?! The servlet.jar file also needs to be in JAVA_HOME/jre/lib/ext/.

Does anyone know why MultipartRequest could not find this class in the TOMCAT_HOME/common/lib?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!