2
votes

I have two windows domains A and B.

I have two servers: nasB on domain B, and webserverA on domain A.

I have two users: userB on domain B and access to nasB and userA on domain A with access to webserverA

I am running tomcat as a service on webserverA and it has the logon as property set to userA.

I have \\nasB\myFiles$\ mapped on webserverA using userB credentials. The mapping is only to allow the JVM access. I always access the drive using UNC in the code. I also have credentials in the manage network passwords. Both methods work when running any java app directly but not as a service :(

If I run tomcat as a service it throws a filenotfound except when trying to access \\nasB\myFiles$\somefile.txt. If I run tomcat using the startup.bat it can access the file fine.

I cannot run tomcat service using userB as he does not have access to webserverA. How do I let my tomcat service use the userB credentials when accessing nasB?

2
"If I run tomcat using the startup.bat it can access the file fine" - which user are you logged in as when you do that? - Martin Wilson
userA. But as I noted he has nasB mapped using userB credentials. Also, I am using UNC in all locations not the map drive letter. - Daniel Moses

2 Answers

3
votes

Don't try using mapped drives.

Given the fact users' configuration and mapped drives are available only if the user logins using interactive login, you won't be able to use such resources. Try with UNC paths and, if that doesn't work due to user restrictions, get a hand over jcifs library, it is quite handy in those cases because it allows you to authenticate when accesing the resource with the UNC path, so it reduces uncertainty about ability to read folders and files in network drives (also, configuring tomcat service to be ran as an administrative user, giving credentials that shouldn't expire,...).

I' ve faced this myself and this is just my personal view.

0
votes

Create Windows user with username/password identical on both Windows servers. Example userA/passA Then run Tomcat Windows service with that user.