Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException in MultipartRequest--Help In this

 
Saravanan V
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic