Home arrow static arrow Java Programming [Archive] - Paths of files not being recognized when Tomcat is made a windows service
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Paths of files not being recognized when Tomcat is made a windows service
This topic has 4 replies on 1 page.

Posts:30
Registered: 2/24/04
Paths of files not being recognized when Tomcat is made a windows service  
May 20, 2004 5:20 AM



 
Hi,

I have a problem with tomcat made a win2k service on my system. It is installed in C drive. "C:\Tomcat-4.0".

I am developing an application which internally needs to recognise a script file and see whehter it exists or not.

Here is a sample code of my servlet.

import java.io.*;
import javax.servlet.*;

public class Test extends GenericServlet
{
public void service(ServletRequest req, ServletResponse res)
{
String strScriptFile = "W:
";
strScriptFile += "L5_QE";
strScriptFile += "\\L5A\\Initial
script";
File f = new File(strScriptFile);

if (!(f.exists()))
{
System.out.println("Script Does not exist: " + strScriptFile);
}
else
{
//Do some thing else
}
}
}

Here I am trying to check if a file exists in the location "W:\\L5_QE\L5A\Initial\script". Here 'W' is a mapped network drive.

When Tomcat is made a service on my machine The condition always succeds and the program says "The script file does not exist", but the file actually exists.

When Tomcat is not a windows service, the file is recognized correctly. The problem occurs when Tomcat is made a windows service.

Can any one please tell me how do I deal with this.

Thanks,
Ramesh
 

Posts:6,487
Registered: 5/5/04
Re: Paths of files not being recognized when Tomcat is made a windows service  
May 20, 2004 5:24 AM (reply 1 of 4)



 
When tomcat is running as a service, what user is it running as. Unusually a service has minimal priviledges
It is possible that user cannot read the network drive?
 

Posts:3,055
Registered: 18/06/98
Re: Paths of files not being recognized when Tomcat is made a windows service  
May 20, 2004 5:44 AM (reply 2 of 4)



 
Mapped drives usually are not available to services because they run under a different user. The "W:" drive appears to be a mapped drive.

Try replacing "W:" by the real name of the share (for instance, "\\\\themachine
theshare", and try again. You will probably have problems with the access because the service usually runs under the "LOCAL SYSTEM SYSTEM" or the "NETWORK SERVICE" account. You will have to go to the Control Panel, Services, choose the Tomcat service, and change the user (choose the tab "Log On", check the radio button (.) This Account, and use a real account that has access to the share you need to use.
 

Posts:30
Registered: 2/24/04
Re: Paths of files not being recognized when Tomcat is made a windows service  
May 20, 2004 6:10 AM (reply 3 of 4)



 
Hi,

I am sorry. Tomcat as Win2k service is recognising mapped network paths correctly. But the problem is with windows XP. Sorry for the mistake I made initially.

Thanks,
Ramesh
 

Posts:28
Registered: 12/18/02
Re: Paths of files not being recognized when Tomcat is made a windows service  
Aug 5, 2004 2:35 PM (reply 4 of 4)



 
Hi,

I am sorry. Tomcat as Win2k service is recognising
mapped network paths correctly. But the problem is
with windows XP. Sorry for the mistake I made
initially.

Thanks,
Ramesh

What was the problem with Windows XP? I'm having the same issue.
 
This topic has 4 replies on 1 page.