aspose file tools*
The moose likes Servlets and the fly likes NullPointerException in MultipartRequest--Help In this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "NullPointerException in MultipartRequest--Help In this" Watch "NullPointerException in MultipartRequest--Help In this" New topic
Author

NullPointerException in MultipartRequest--Help In this

Saravanan V
Greenhorn

Joined: Sep 20, 2001
Posts: 15
Hi
I am using Oreilly package for file upload.In that i am getting NullPointerException for the MultipartRequest.Can anyone help in this.I have included the jar file in the classpath and in the form tag also i am passing as "multipart/form-data".Help me to solve out this.
MultipartRequest multi=new MultipartRequest(request,directory,uploadsize)
In this i am getting the NullPointerException.
Thanx
Saravanan V.
Saravanan V
Greenhorn

Joined: Sep 20, 2001
Posts: 15
Hi
To add some more to my above query...the same thing was working well with websphere appl server and now when i use it in weblogic its throwing this error(NullPointerException)..I have checked for the request object and the content type and length.Everything seems to be fine.Can anyone explain in detail reg this.
Wishes
Saravanan
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Saravanan V",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

One thing to consider is that perhaps the different web containers may or may not try to parse the multipart request and make a mess of it.

Could you also be more specific about your error? Show us a stack trace and show us the code where you call it.. ie: show us if you try to use the request object before you send it to the MultipartRequest constructor.
Saravanan V
Greenhorn

Joined: Sep 20, 2001
Posts: 15
Hi
I have posted the same query again with another login id.Anyway here i am attaching the stack trace.
Error :-
java.lang.NullPointerException
at uploadFiles.doPost(uploadFiles.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java, Compiled Code)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java, Compiled Code)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java, Compiled Code)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java, Compiled Code)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java, Compiled Code)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java, Compiled Code)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
Exception:java.lang.NullPointerException
******
Also when i get the request.getContentType() and request.getContentLength() prints "multipart/form-data" and the content length.what could be the other possibility of error.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

*When* do you get the getContentType() of the request? Before or after you send it to the MultipartRequest constructor?

In your doPost method, ensure that the VERY first thing you do with the request, before ANYTHING else, is send it to the MultipartRequest constructor.

Try this and report back. If you are already doing this, I'm not sure what else the problem might be.
Saravanan V
Greenhorn

Joined: Sep 20, 2001
Posts: 15
Hi Mike
Thanx for ur reply.
I made a mistake of not including the cos.jar file in the web application's web-inf\lib directory.I had given in the classpath.Now its working fine.
Saravanan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException in MultipartRequest--Help In this
 
Similar Threads
Problem using oreilly,multipart-request with Websphere 5.1
File Upload
NullPointerException in MultipartRequest--Urgent
MultipartRequest cannot be resolved to a type
How to repalce cos.jar with Java commons fileupload