tomcat as Windows service - access to resources

2005-04-07 Thread Jiang, Peiyun
I'm running Tomcat 5.0 on Windows 2000. I logon to Windows as user1 and I have 
a mapped drive G: that requires separate login (I user the same user name and 
password, so it automatically logs in). 
(1) If I login as user1 and start Tomcat from the start script, I can access 
drive G: from a servlet.
(2) If I login as user1 and run Tomcat as a Windows service, I don't have 
access to G: from a servlet. Even if I change the service property using user1 
to log on, I still don't have access to G: from a servlet.

Is there a workaround? Is it because when you run tomcat as a service, user1 is 
not the owner of the process even if you use user1 as log on?

Thanks.

Peiyun Jiang

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: tomcat as Windows service - access to resources

2005-04-07 Thread Peter Crowther
 From: Jiang, Peiyun [mailto:[EMAIL PROTECTED] 
 I'm running Tomcat 5.0 on Windows 2000. I logon to Windows as 
 user1 and I have a mapped drive G: that requires separate 
 login (I user the same user name and password, so it 
 automatically logs in). 
 (1) If I login as user1 and start Tomcat from the start 
 script, I can access drive G: from a servlet.
 (2) If I login as user1 and run Tomcat as a Windows service, 
 I don't have access to G: from a servlet. Even if I change 
 the service property using user1 to log on, I still don't 
 have access to G: from a servlet.

Processes that run as services don't load the user profile of the user,
they just take on the user's network identity.  Amongst other things,
the profile stores drive mappings.  This means that no service (to my
knowledge) gets any drive mappings.  A typical workaround is to use the
UNC name of the mapped drive.

- Peter

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: tomcat as Windows service - access to resources

2005-04-07 Thread Jiang, Peiyun
I did a test using \\computer\dir\mydir instead of a mapping G:. I still have 
the same behavior.

Is there any other reason?

Peiyun

-Original Message-
From: Peter Crowther [mailto:[EMAIL PROTECTED]
Sent: April 7, 2005 10:11 AM
To: Tomcat Users List
Subject: RE: tomcat as Windows service - access to resources


 From: Jiang, Peiyun [mailto:[EMAIL PROTECTED] 
 I'm running Tomcat 5.0 on Windows 2000. I logon to Windows as 
 user1 and I have a mapped drive G: that requires separate 
 login (I user the same user name and password, so it 
 automatically logs in). 
 (1) If I login as user1 and start Tomcat from the start 
 script, I can access drive G: from a servlet.
 (2) If I login as user1 and run Tomcat as a Windows service, 
 I don't have access to G: from a servlet. Even if I change 
 the service property using user1 to log on, I still don't 
 have access to G: from a servlet.

Processes that run as services don't load the user profile of the user,
they just take on the user's network identity.  Amongst other things,
the profile stores drive mappings.  This means that no service (to my
knowledge) gets any drive mappings.  A typical workaround is to use the
UNC name of the mapped drive.

- Peter

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: tomcat as Windows service - access to resources

2005-04-07 Thread Jason Bainbridge
On Apr 7, 2005 10:59 AM, Jiang, Peiyun [EMAIL PROTECTED] wrote:
 I did a test using \\computer\dir\mydir instead of a mapping G:. I still have 
 the same behavior.

Silly question but did you escape your backslashes? What errors are
you getting? More details would help.

Regards,
-- 
Jason Bainbridge
http://kde.org - [EMAIL PROTECTED]
Personal Site - http://jasonbainbridge.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: tomcat as Windows service - access to resources

2005-04-07 Thread Jiang, Peiyun
I escaped them. It's working if tomcat started from a script. The servlet 
cannot see the directory as a java File.
Testing for file.exist() returns false.

Peiyun

-Original Message-
From: Jason Bainbridge [mailto:[EMAIL PROTECTED]
Sent: April 7, 2005 12:03 PM
To: Tomcat Users List
Subject: Re: tomcat as Windows service - access to resources


On Apr 7, 2005 10:59 AM, Jiang, Peiyun [EMAIL PROTECTED] wrote:
 I did a test using \\computer\dir\mydir instead of a mapping G:. I still have 
 the same behavior.

Silly question but did you escape your backslashes? What errors are
you getting? More details would help.

Regards,
-- 
Jason Bainbridge
http://kde.org - [EMAIL PROTECTED]
Personal Site - http://jasonbainbridge.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: tomcat as Windows service - access to resources

2005-04-07 Thread Jason Bainbridge
On Apr 7, 2005 11:11 AM, Jiang, Peiyun [EMAIL PROTECTED] wrote:
 I escaped them. It's working if tomcat started from a script. The servlet 
 cannot see the directory as a java File.
 Testing for file.exist() returns false.

So your path within your servlet looks like:

computer\\dir\\mydir

(Note the four back slashes at the beginning)?

And this is while the service is running under the user account? IS
the User Account a domain account?

Again posting details will help a lot, posting a snippet of code isn't
that hard.

Regards,
-- 
Jason Bainbridge
http://kde.org - [EMAIL PROTECTED]
Personal Site - http://jasonbainbridge.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: tomcat as Windows service - access to resources

2005-04-07 Thread Jiang, Peiyun
(1) a property is set: cops.monitoredDirectory.win=dove\\copsxml\\Final
(2) It's then loaded into a Configuration class
(3) It's then passed as a parameter: pathname and the following code is run:

try {
File file = new File(pathname);

if (file.exists()  file.canRead()) {
watchedFilesVec.add(file);
logger.info(add monitored directory  
+ file.getAbsolutePath());
} else {
if (file.exists()) {

logger.warn(file.getAbsolutePath() +  exist but cannot read);
} else {

logger.warn(file.getAbsolutePath() +  not exist);
}
}
} catch (Exception e) {
logger.error(addWatchedFile(String pathname)  
+ e);
}

No Rrror or Exception as file.exists() returns false. It's just not seeing the 
directory.

log file output:
2005-04-07 12:09:50,171 DEBUG (ArticleMonitor.java:117) - addWatchedFile(String 
pathname) start
2005-04-07 12:09:50,187  WARN (ArticleMonitor.java:133) - \\dove\copsxml\Final 
not exist
2005-04-07 12:09:50,187 DEBUG (ArticleMonitor.java:163) - addWatchedFile(String 
pathname) end

Peiyun

-Original Message-
From: Jason Bainbridge [mailto:[EMAIL PROTECTED]
Sent: April 7, 2005 12:19 PM
To: Tomcat Users List
Subject: Re: tomcat as Windows service - access to resources


On Apr 7, 2005 11:11 AM, Jiang, Peiyun [EMAIL PROTECTED] wrote:
 I escaped them. It's working if tomcat started from a script. The servlet 
 cannot see the directory as a java File.
 Testing for file.exist() returns false.

So your path within your servlet looks like:

computer\\dir\\mydir

(Note the four back slashes at the beginning)?

And this is while the service is running under the user account? IS
the User Account a domain account?

Again posting details will help a lot, posting a snippet of code isn't
that hard.

Regards,
-- 
Jason Bainbridge
http://kde.org - [EMAIL PROTECTED]
Personal Site - http://jasonbainbridge.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]