FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-29212-20040415-1348-win-ia32,
Native Threads, GC strategy: parallel)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
When a java class is started as a Windows service, it does not list the files on a mapped network drive. (It will display the files on a local drive.)
I was using the latest Java 1.3.1_X version to test this and it happens on all 1.3.1_X releases and all 1.4.2_X releases as well.
This looks like a bug because if the same java class is run from the command line it will return the files from a mapped network drive.
I then saw http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4701462 but the suggested workaround of using java.io.File.list() does not work when it is started as a Windows Service (only works from the command line). The code is listed below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Install the Java class as a service in some manner and when it is started, the output printed will not show the list of files from the mapped network drive. If it is run from the command line then the information is displayed. This will happen with JDK 1.4.2_X and also JDK 1.3.1_X (all patched versions.)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The list of files from the mapped network drive should be displayed when the Java class is run as a Windows Service.
ACTUAL -
It just printed out the information from listRoots() and not listFiles(). You can see this in the code below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
This is the test code:
import java.io.*;
public class TestFile {
public static void main(String args[]) {
try {
String version = System.getProperty("java.vm.version") + "\n";
BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));
bw.write(version,0,version.length());
File f = new File("");
File files [] = f.listRoots();
for (int i = 0;i < files.length;i++) {
String s = "the folder is ..."+files[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
File f1 = new File("f:\\");
File files1 [] = f1.listFiles();
for (int i = 0;i < files1.length;i++) {
String s = "the files are ..."+files1[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
bw.close();
} catch(Exception e) {
e.printStackTrace();
} // of try
} //of main
} //of class
So if this is run from the command line we'll list info from listRoot() and then listFiles() on F:\ (for example):
1.3.1_10-b03
the folder is ...C: the folder is ...D: the folder is ...E: the folder is ...F: the files are ...f:\webhome
the files are ...f:\certificate.war
the files are ...f:\.popbull
the files are ...f:\.sh_history
the files are ...f:\mbox
When it is started as a Windows service, it just lists the info from listRoots() and *nothing* from listFiles() on F:\ (for example):
1.3.1_10-b03
the folder is ...C: the folder is ...D: the folder is ...E: the folder is ...F:
I then saw http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4701462 but the suggested workaround of using java.io.File.list() does not work when it is started as a Windows Service (only works from the command line). This was the modified code with File.list() used instead of File.listFiles():
import java.io.*;
public class TestFile {
public static void main(String args[]) {
try {
String version = System.getProperty("java.vm.version") + "\n";
BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));
bw.write(version,0,version.length());
File f = new File("");
File files [] = f.listRoots();
for (int i = 0;i < files.length;i++) {
String s = "the folder is ..."+files[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
File f1 = new File("f:\\");
String files1 [] = f1.list();
for (int i = 0;i < files1.length;i++) {
String s = "the files are ..."+files1[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
bw.close();
} catch(Exception e) {
e.printStackTrace();
} // of try
} //of main
} //of class
It showed the same results.
---------- END SOURCE ----------
###@###.### 2005-2-11 07:00:42 GMT
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-29212-20040415-1348-win-ia32,
Native Threads, GC strategy: parallel)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
When a java class is started as a Windows service, it does not list the files on a mapped network drive. (It will display the files on a local drive.)
I was using the latest Java 1.3.1_X version to test this and it happens on all 1.3.1_X releases and all 1.4.2_X releases as well.
This looks like a bug because if the same java class is run from the command line it will return the files from a mapped network drive.
I then saw http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4701462 but the suggested workaround of using java.io.File.list() does not work when it is started as a Windows Service (only works from the command line). The code is listed below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Install the Java class as a service in some manner and when it is started, the output printed will not show the list of files from the mapped network drive. If it is run from the command line then the information is displayed. This will happen with JDK 1.4.2_X and also JDK 1.3.1_X (all patched versions.)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The list of files from the mapped network drive should be displayed when the Java class is run as a Windows Service.
ACTUAL -
It just printed out the information from listRoots() and not listFiles(). You can see this in the code below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
This is the test code:
import java.io.*;
public class TestFile {
public static void main(String args[]) {
try {
String version = System.getProperty("java.vm.version") + "\n";
BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));
bw.write(version,0,version.length());
File f = new File("");
File files [] = f.listRoots();
for (int i = 0;i < files.length;i++) {
String s = "the folder is ..."+files[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
File f1 = new File("f:\\");
File files1 [] = f1.listFiles();
for (int i = 0;i < files1.length;i++) {
String s = "the files are ..."+files1[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
bw.close();
} catch(Exception e) {
e.printStackTrace();
} // of try
} //of main
} //of class
So if this is run from the command line we'll list info from listRoot() and then listFiles() on F:\ (for example):
1.3.1_10-b03
the folder is ...C: the folder is ...D: the folder is ...E: the folder is ...F: the files are ...f:\webhome
the files are ...f:\certificate.war
the files are ...f:\.popbull
the files are ...f:\.sh_history
the files are ...f:\mbox
When it is started as a Windows service, it just lists the info from listRoots() and *nothing* from listFiles() on F:\ (for example):
1.3.1_10-b03
the folder is ...C: the folder is ...D: the folder is ...E: the folder is ...F:
I then saw http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4701462 but the suggested workaround of using java.io.File.list() does not work when it is started as a Windows Service (only works from the command line). This was the modified code with File.list() used instead of File.listFiles():
import java.io.*;
public class TestFile {
public static void main(String args[]) {
try {
String version = System.getProperty("java.vm.version") + "\n";
BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));
bw.write(version,0,version.length());
File f = new File("");
File files [] = f.listRoots();
for (int i = 0;i < files.length;i++) {
String s = "the folder is ..."+files[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
File f1 = new File("f:\\");
String files1 [] = f1.list();
for (int i = 0;i < files1.length;i++) {
String s = "the files are ..."+files1[i]+"\n";
bw.write(s,0,s.length());
}
bw.flush();
bw.close();
} catch(Exception e) {
e.printStackTrace();
} // of try
} //of main
} //of class
It showed the same results.
---------- END SOURCE ----------
###@###.### 2005-2-11 07:00:42 GMT