This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Create folder in a remote machine - failing silently Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Create folder in a remote machine - failing silently" Watch "Create folder in a remote machine - failing silently" New topic
Author

Create folder in a remote machine - failing silently

Tapas Pradhan
Greenhorn

Joined: Oct 23, 2012
Posts: 2
I have a webapp deployed in tomcat. All I want to do is create a folder in remote machine, accessible through LAN, like say //FileServer/Filocation/temp. I'm using a code like (new File(<{filelocation}>)).mkdirs so that all missing directories are created. It works when I change <{filelocation}> to say C:/Temp it works. When I point to lan location //FileServer/Filelocation/temp it always return false, indicating filke was not created. It doesn't throw any exceptions and nothing in LOGS to tell me anything.

1. Asked sysadmins to run tomcat under the domain user, who has permissions to the LAN location. I didn't solve anything.
2. Is there any conf files in tomcat, where I should give access to the user to access LAN or something? I don't even know where to start looking for it.

Any help on this is appreciated!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18151
    
    8

If you're running Tomcat as a Windows service (which it sounds like you are) then you have to run the service as a specific user who has access to the UNC path in question. Those generic user accounts aren't good enough.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

Welcome to the JavaRanch, Tapas!

Tomcat doesn't know or care about specific details of fileshares. So there are no options to set.

However, if you are attempting to access the fileshare using its UNC path, that won't work because the core java.io.File classes don't support UNC. You need to map the share to an actual drive letter and use the drive-based path, instead. Something like: " W:/Filocation/temp".


Customer surveys are for companies who didn't pay proper attention to begin with.
Tapas Pradhan
Greenhorn

Joined: Oct 23, 2012
Posts: 2
Thanks Tim and Paul, for quick response. It's working fine now, after restarting the service under specific user.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create folder in a remote machine - failing silently
 
Similar Threads
servlet API
Download file on client machine at particular location
Access resources on mapped drives
context root
Cannot create PoolableConnectionFactory