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

Discrepancy in listing of a file using Windows Explorer and JAVA I/O classes  RSS feed

 
Abhishek Itbhu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are network storage servers which are excessed using Windows file path like \\ARCHIVE01\MEDIA.

Now when I try to access some ofthese storage servers using Windows Explorer using a user's credentials I am able to see the contents.

I can even list the file/directories at Command prompt using the same user credential.

But in one of my JAVA web application when I try to get the list of File/Directories using JAVA I/Oit gives me null. The application registers the same user with SecurityManager as the one used above to see the contents using Windows Explorer. And the user has Read and List permission for the share.

Someone please suggest the reason for discrepancy.

Snippet of code to List

==================

File f=new File("\\\\ARCHIVE01\\MEDIA");
boolean isFileReadable=f.canRead();
System.out.println("isFileReadable "+isFileReadable);//Returns true
File[] files=f.listFiles();
out.println("files "+files);//Returns null

================
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web application? Is this web application perhaps a server which is running as a Windows service?

If that's the case then such a service cannot access files via a UNC path, unless you configure the service to login as a specific user which has permissions for that path. Having the service run as "local service" or even "network service" doesn't work.
 
Abhishek Itbhu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the Web Application is deployed on Tomcat Server or more appropriate to say, a wrapper to Tomcat server.

This wrapper has a System Monitor accessible through browser which is used to Start/Stop the Web server.

And the access to System Monitor is via Browser User authentication and the user credentials are used to configure the server to log in as a specific user.

So for the same user I am able to access other shares using UNC in my web application. This behavior i.e. not listing the contents is happening for very few shares, though when I check the permissions of the share(the one for which not getting listed) they are same as that for the one for which its getting listed.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!