wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Not able to access Network Drive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Not able to access Network Drive" Watch "Not able to access Network Drive" New topic
Author

Not able to access Network Drive

Prabhat Kumar
Greenhorn

Joined: Jan 25, 2007
Posts: 27
Hi,

I am running Tomcat 6 in Windows Server 2003 operating system. I have a problem accessing network shared drives from within my servlets and JSP-pages.

For instance, if "S" is a mapped drive pointing to something like a
shared network drive "\\shared_server\shared_drive", then this scriplet
returns
"false":

<%
java.io.File file = new java.io.File("S:/test.txt");
boolean exists = file.exists();
out.print("exists: " + exists);
%>

The file "test.txt" does exist, but Tomcat does not see the shared
drive.

Please help.

Thanks,

Prabhat
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Presumably Tomcat is running as a Windows service. Windows services don't have any network drives mapped.

You could probably deal with that by using the UNC path for the share instead of the version of the path which assumes that a drive has been mapped. But if you do that, make sure the Tomcat service is running as a user which has access to that share. Services which are logged on as the local system account don't have access to UNC paths either.
Prabhat Kumar
Greenhorn

Joined: Jan 25, 2007
Posts: 27
Hi,

Thanks for your reply.

How should i user UNC path (sorry, i am bit novice) and how should i get assured that my tomcat is running using which user account?

Prabhat
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Prabhat Kumar wrote:How should i user UNC path (sorry, i am bit novice) and how should i get assured that my tomcat is running using which user account?


The UNC path is just like what you posted as an example: \\shared_server\shared_drive

To configure a service to log on as a specific user, go to the Services in the Control Panel (via Administrative Tools). Right-click on the service, select Properties and go to the Log On tab. Enter the user ID and its password.
Prabhat Kumar
Greenhorn

Joined: Jan 25, 2007
Posts: 27
I changed the user as you suggested. It worked. Thanks very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to access Network Drive