• 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

java.lang.IllegalArgumentException: Not a directory:

 
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am uploading file to the path described in the properties file. On windows its working fine with tomcat but when I am uploading to our dedicated server then it throws error:

Path I provided in properties file is:

but why its (adding /var/java/aache-tomcat-7.0.47/webapps/project) extra on the linux server:


I am using Orielly' File upload API

Please advise

Best regards
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do not "upload a file to a path". File upload works by a mechanism where the client-side file is opened by the client application (browser) and its data is MIME-encoded and copied into the request data stream that is sent to the server.

Once the server recieves that request, the file data is parsed out of it, but that doesn't make it a "file". The server can hold the data anywhere it wants to, including in memory.

The file upload API allows you to take that data and - using your own code - process it. You can simply read it and do computations or whatever, you can copy it into a BLOB in a database, or you can create a file on the server's filesystem and write the data returned from the file API into it. Which is what you appear to wish to happen.

The "not a directory" problem is most likely that you are setting a relative path rather than an absolute path and you are appending an (assumed) "absolute" path to that relative path.

Relative paths are dangerous in web applications, because a relative path is relative to the current working directory and there is no such thing in J2EE. If you use the general working directory mechanisms in a J2EE application, the results are unpredictable.

An absolute path should ALWAYS start with a "/". Even in Windows, it's recommended that you code paths in the format "/C:/directory1/directory2/myfile.dat". In Unix/Linux, there's no other way for the pathname parser to properly interpret an absolute path if it doesn't begin with a slash.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your favorable detailed reply. This fixed my problem.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic