Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with usage of java.io.File in a webapp  RSS feed

 
Sharma Vedula
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a web application for my users to access our File server from outside our netwok. And in doing so, I am using the java.io.File to check if a certain folder exists on the file server. When I run a simple java application using that path, it is able to find it, but when I put the same piece of code in a Servlet, it is not able to find that folder. FYI, the path and the folder I am trying to reach is on a different server on the same network. I am not sure what's the reason for this. Any help would be greatly appreciated. Here is the code snippet:

File f = new File("\\192.168.53.16\Clients");
System.out.println(f.getAbsolutePath());
System.out.println("****f: " + f.exists())

Thanks

Sharma
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
 
Sharma Vedula
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using it, but the method, f.exists() returns false, indicating that the directory denoted by the file's absolute path name does not exist. Am I missing anything? Here is the updated code:

f = new File(path);
URI uri = f.toURI();
LOGGER.info("URI in FileAccess:"+uri.getPath());
LOGGER.info("URI HOST: " + uri.getHost());
LOGGER.info("****f exists: " + f.exists());
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like Windows. Your servlet is running in some application container which you didn't mention its name, right? I'm going to go farther and guess that you're running that application container as a Windows service. And I'm going to go even farther and guess that you didn't configure this service to run as a user which has access to that remote server.

Am I right? If so, you'll need to configure the service to run as a specific user. Make sure the user is permitted suitable access to the remote server.
 
Sharma Vedula
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right, I did not mention the app server. I am using Tomcat 6. The issue I am having is when I run from one server which is a Windows 2008 server, it seems to be able to access the folder (which BTW is running on Windows 2008 server as well). But when I run the same app on a different server using Tomcat 5 and Windows 2003, it is not able to access the same folder. And on the server that is able to access just fine, I am just using the default Tomcat user (local system) to connect to the file server. Not sure what else to do.

Is there a way, I can find out which user is trying to access this folder on the remote server?

Thanks

Sharma
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. Just ask whoever is running the Tomcat version what their user ID is. (I assume that it isn't running as a service or you would have said so, in response to what I posted.)
 
Sharma Vedula
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to have left out that piece of information, but it is running as a service on both the servers - Windows 2003 and Windows 2008.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!