• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not A Directory - MultipartRequest problem

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting a java.lang.IllegalArgumentException when using the com.oreilly.servlet.MultipartParsrer class.
Here's the error:


Error: 500
Location: /accessability/newsupload.jsp
Internal Servlet Error:
javax.servlet.ServletException: Not a directory: http://www.lucidity.dev/accessability/images/
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at accessability.newsupload_3._jspService(newsupload_3.java:120)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:341)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:534)
Root cause:
java.lang.IllegalArgumentException: Not a directory: http://www.lucidity.dev/accessability/images/
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:214)
at upload.uploadBean.doUpload(uploadBean.java:95)
at accessability.newsupload_3._jspService(newsupload_3.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:341)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:534)


Now, the directory specified is most definitely a directory. I've changed it many times to see will it accept any directory value, but it won't. The bean I use is uploadBean.java, in the package upload. Initially, I had my com.oreilly classes in this upload package, but that caused different problems, so I put the "com" folder in my WEB-INF/classes. That's when this error began.
In my JSP:
Vector vctInfo = new Vector();
vctInfo = uploadBean.doUpload(request);
In my bean's "doUpload" method:
MultipartRequest multi =new MultipartRequest(request, "http://www.lucidity.dev/accessability/images/", 10*200*200,
"ISO-8859-1", new DefaultFileRenamePolicy());

Has anyone had this problem or anything similar?
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In my bean's "doUpload" method:
MultipartRequest multi = new MultipartRequest(request, "http://www.lucidity.dev/accessability/images/", 10*200*200,
"ISO-8859-1", new DefaultFileRenamePolicy());


Why are you using the full path http://www.lucidity.dev/accessability/images/
place your images directory in /defaultroot folder and use getServletContext().getRealPath("/images") method to get the real path of the images directory
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are using a URL to specify the directory. This must be the actual path to the file in the file system, not a URL.
If the file is to be stored within the boundaries of the web app (not a great idea in my opinion), the getRealPath() method can be used to determine the path as Ali pointed out.
The most common schenario is for the path for uploaded files to be provided as an init parameter in either a properties file or directly in the web.xml as a context parameter as appropriate.
 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks lads, that worked.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic