aspose file tools*
The moose likes I/O and Streams and the fly likes System cannot find the path specified 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 » Java » I/O and Streams
Bookmark "System cannot find the path specified" Watch "System cannot find the path specified" New topic
Author

System cannot find the path specified

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
I have mapped my "R" drive to a network shared location (I have read/write access to this shared location)

When I am trying to create file using Servlet Action class I get the following error
R:\SUNONELOCAL.txt (The system cannot find the path specified)

but if I try to do the same through standalone program it works fine

Can anyone please suggest what could be the reason for it

Thanks in advance


From standalone program


From Action class code is



SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Two reasons:
(1) In windows, a mapped network drive is per user only -> if you see the network path under R: doesn't mean that the service account running servlet container can see it on R:
(2) Anyway for security reasons, the default window service account won't be able to access network drives. Hence even if you use the full network location (\\server\etc.) it still won't work.

“Everything should be as simple as it is, but not simpler.” Albert Einstein
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Duc Vo wrote:(1) In windows, a mapped network drive is per user only -> if you see the network path under R: doesn't mean that the service account running servlet container can see it on R:
(2) Anyway for security reasons, the default window service account won't be able to access network drives. Hence even if you use the full network location (\\server\etc.) it still won't work.


Yes, that's true. And if you need your servlet to have access to a UNC path like \\server\etc, here's what you have to do:

  • Create a user profile which has read/write access to that path (don't use your account, make a new one just for this)
  • Configure the service where the servlet container runs, and have it log in as that user profile
  • Gaurav Chikara
    Ranch Hand

    Joined: Jun 09, 2000
    Posts: 410

    Yes, that's true. And if you need your servlet to have access to a UNC path like \\server\etc, here's what you have to do:

  • Create a user profile which has read/write access to that path (don't use your account, make a new one just for this)
  • Configure the service where the servlet container runs, and have it log in as that user profile


  • Thanks a lot for the reply
    I am not sure how to achive the point 2 suggested. Is there some help around (which you are available that can help me in knowing its details)

    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18669
        
        8

    Open the "Services" tool from the Windows control panel. Right-click the service you want to work with and click "Properties". It's in there somewhere, just look around.
    Rob Spoor
    Sheriff

    Joined: Oct 27, 2005
    Posts: 19722
        
      20

    Services is within the Administrative Tools folder inside the control panel. Double click on the service, then go to the Log On tab. Select "This account", then fill in or select the user account and fill in the password twice. Confirm if it asks you to give the user run as service privileges.

    And yes, you'll still need to use \\server\share after that, since shares are only mapped when you login.


    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
    How To Ask Questions How To Answer Questions
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: System cannot find the path specified