-
1. Re: java.io.File.isDirectory() & java.io.File.exists() are not working fine on jboss-as 6.0 for mapped network drive on Windows 2008 R2 (64 bit) machine but the same methods are working fine if called from plain java file (outside Jboss)
stetali Jun 28, 2014 7:00 AM (in response to stetali)Hi,
I have also tried the following on Jboss-as 6.0 :
1) Passing "Mapped Network Drive" (Z:)
(where Z: is actually mapped to \\a.b.c.d\test where a.b.c.d is the ipaddress which is mapped on windows)
try
{
File f = new File("Z:");
boolean ifFileExists = f.exists();
boolean ifFileisDirectory = f.isDirectory();
FileWriter fw = new FileWriter(file,true);
pw = new PrintWriter(fw);
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Exception : " + e.getMessage());
e.printStackTrace();
}
finally
{
if(pw!=null)
pw.close();
}
Output : f.exists() & f.isDirectory() returned false.
Exception obtained is "java.io.FileNotFoundException: Z: (The system cannot find the path specified)
2) Passing Network Path directly
try
{
File f = new File("\\a.b.c.d\test");
boolean ifFileExists = f.exists();
boolean ifFileisDirectory = f.isDirectory();
FileWriter fw = new FileWriter(file,true);
pw = new PrintWriter(fw);
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Exception : " + e.getMessage());
e.printStackTrace();
}
finally
{
if(pw!=null)
pw.close();
}
Output : f.exists() & f.isDirectory() returned false.
Exception obtained is "java.io.FileNotFoundException: \\a.b.c.d\test (Access is denied)"
Gave a valid accessible network ipaddress in the place of "a.b.c.d" above.
As seen above, in case 2, Path is identified atleast but access is denied but still f.exists(), f.isDirectory() returned false
Thanks & Regards,
stetali.
-
2. Re: java.io.File.isDirectory() & java.io.File.exists() are not working fine on jboss-as 6.0 for mapped network drive on Windows 2008 R2 (64 bit) machine but the same methods are working fine if called from plain java file (outside Jboss)
ctomc Jul 1, 2014 5:58 AM (in response to stetali)This has noting to do with JBoss AS itself, but more general java.io.File problems.
And to be fair,there are many.
I would recommend you to use JDK7 and use http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html api as it will solve lots of your problems.
-
3. Re: java.io.File.isDirectory() & java.io.File.exists() are not working fine on jboss-as 6.0 for mapped network drive on Windows 2008 R2 (64 bit) machine but the same methods are working fine if called from plain java file (outside Jboss)
stetali Jul 1, 2014 2:29 PM (in response to ctomc)Hi Tomaz Cerar,
Thanks for your reply. The issue got resolved on JDK6 itself by doing the following :
1) Stopped Jboss service
2) Added "net use <drive letter>:\\<SERVERNAME>\<SERVERPATH> /user:<LocalSystemAccountUser> <LocalSystemAccountPassword>" to service.bat
For ex : net use Z: \\1.1.1.1\testDirectory /user:Administrator admin
3) Started Jboss service
Hence, this might be happening because Jboss service on Windows is in local system account and adding the above statement makes the service use mapped network drive also for its operations.
I feel that if JDK6 is the issue, then it wouldn't have run correctly when sample java program was run on same JDK6 outside Jboss which was not happening. This looks like an issue with service accessibility to network path on Windows.
But thanks a lot for your feedback. I can try to use JDK7 and see if it works even by not adding this entry in service,bat. Kindly, let me know if you have any other thoughts on it.
Thanks & Regards,
stetali.