views:

51

answers:

3

Hello All, I've a production env and test env. Production has win2k3+tomcat 6.0+ and network drive mapped to a drive letter for easy access (z:\app instead of \symba\files\app). My test env has windows xp (all the software is same including the source code for servlet) and test also has the same drive letter mapping to the network drive.

Tomcat is running with the same user id in both the systems and am able to access the file via windows explorer in the test m/c and production m/c.

Now the servlet in the windows xp m/c (test m/c) throws a file not found exception if try to access an existing file (reachable via windows explorer). The servlet in production is same as in test env and production servlet happily gives the file when i request it and does not throw any error what so ever.

I've see some posts that using drive letter is not a good idea and should use UNC paths instead and i've not tried this yet. I want to know the reason why test servlet fails to get file whereas production servlet works fine.

Thank you very much for your time and help Bo

+1  A: 

Are you running the application server as a service? Drive letter assignments are reliable only if you use interactive programs not services.

A couple of years ago, I tried to resolve a quite identical problem but, at last, I gave up and I used JCIFS to access the files.

andcoz
yes am running the tomcat as a service in both the envs. You are right about interactive programs because i can access the file in win explorer. Dont know about jcifs but will try to see if it fits my problem.
BoCode
andcoz....you are a genius. Yes tomcat in test env was running as a service and in production it was running as an interactive service. I made the test tomcat server run as interactive service (basically remove it as a service and run it thru startup.bat) and now the files are accessible on network drive.
BoCode
A: 

If you run Tomcat with a security manager, the web app code is according to the default configuration only allowed file access to its deployment directory. If you want to change the application policies, you can do that in conf/catalina.policy or you can disable the security manager, if you want your web app code to gain all privileges.

jarnbjo
I'll try and see if there is a change in the catalina.policy in both the envs.
BoCode
just an update, am not running tomcat with any security manager. so i dont know what to do now. can you please help?
BoCode
A: 

You might want to consider running the Tomcat service as the user who has access to the mapped drive.

As pointed out by andcoz, the mappings will not apply for the SYSTEM user in Windows that I presume is being utilized for running Tomcat. You could change the service configuration to run as the user owning the drive mapping and verify if the failure continues to occur.

Related:

FileNotFoundException thrown when the file does exists.

Vineet Reynolds
Vineet this was a great resource. Thank you very very much.
BoCode