• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File dir = new File("\\server\log\");

 
Eugene Wong
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File dir = new File("\\server\log\");
String[] list = dir.list();

Could someone tell me why dir.list() would returns null? It does not when I run my web app from netbeans' tomcat 5.5, but when I deploy my project onto the real apache tomcat 5.5, it could not find the folder. I am running both netbeans and tomcat are the same machine and dir.exists() returns true on netbeans, but false on tomcat. any help would be great, thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there possible a security manager present on Tomcat that prevents it from accessing the directory?
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Is there possible a security manager present on Tomcat that prevents it from accessing the directory?


Hi Ulf, may be i am wrong, but if there is a security manager, would not the list() method throw a SecurityException?
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like, the path you are using is a relative path. So, it will depend on the directory you are running the program in. If it changes which i am sure it does from your IDE to tomcat, it will not be able to find the directory.
 
Eugene Wong
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for your replies.

First of all, there is no Exception being threw here, it returns null and the program continues on it own

Nitesh, I am trying to access a directory which is shared on \\server\log\ (Windows), I don't think it is relative path thats causing this problem. I have tried using \\\\server\\log\\, still no luck.

any help is appreicated.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to keep hammering on relative path but that's where I usually get confused ... When I use relative paths like that I often log the File.getCanonicalPath (or one of those) just to make sure it is where I think it is. Have you double checked it that way?
 
Eugene Wong
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the solution, it suggested to start the tomcat service as administrator, rather than Local System.

Problem solved, thanks everyone.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic