You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stephen Gray <St...@anu.edu.au> on 2006/06/20 08:39:23 UTC

File system inaccessible to application running under Tomcat

Hello everyone,

I'm having a problem with a java/jsp application running under Tomcat 
5.5.12 on Windows. When I start Tomcat from the system tray application or 
from the windows services window code that checks whether a directory 
exists incorrectly returns false:

         File file = new File(server.dataDirectory);
         if (! file.exists())
             throw new FileNotFoundException("Data directory " + 
server.dataDirectory + " for server " + server.shortName + " does not exist.");

If I comment this out the next piece of code (which gets a list of files in 
the directory) returns no files.

However if I start Tomcat from within either Eclipse (MyEclipse) or 
Netbeans this does not happen - file.exists() returns true and a complete 
list of files is returned.

I'm assuming that there is come configuration option that causes Tomcat not 
to be able to see the local file system but I can't think what it might be 
- I'm not starting Tomcat with a security manager.

Can anyone help?

Thanks very much,
Steve


Stephen Gray
Archive Research Officer
Australian Social Science Data Archive
18 Balmain Crescent (Building #66)
The Australian National University
Canberra ACT 0200

Phone +61 2 6125 2185
Fax +61 2 6125 0627
Web http://assda.anu.edu.au/

Re: File system inaccessible to application running under Tomcat

Posted by Mark Thomas <ma...@apache.org>.
Stephen Gray wrote:
> I'm assuming that there is come configuration option that causes Tomcat
> not to be able to see the local file system but I can't think what it
> might be - I'm not starting Tomcat with a security manager.

When running as a service, tomcat runs under the local system user by
default. This user has no privileges to access network resources
either through UNC paths or mapped drives.

Running from the command line, Tomcat runs as the user currently
logged on and therefore has access to the whatever that user has
access to including mapped drives.

Note that if you change the service to run as a domain user, it still
won't have access to mapped drives but it will have access to network
resources via UNC paths.

HTH,

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org