We're having trouble accessing files and folders on our network from the AS/400 in a Java program called from an RPG program. We're trying to use Java to list files in an arbitrary folder on our network from the AS/400 by calling the Java program from RPG, but we've been mostly unsuccessful resolving most network files or folders in the Java program using the java.io.File API. However, if the same Java program is run on any PC on the network, it works correctly and can locate network files without a problem.
For example, we have other servers on our network that we would like to search from the Java program, but we can only locate files on one server, and only if we use the DNS name instead of the IP address. Example servers are Server1, Server2, and Server3 found at 192.168.10.1, 192.168.10.2, 192.168.10.3, respectively:
new File("//Server1/path/").isDirectory() -> true
new File("//Server2/path/").isDirectory() -> false
new File("//Server3/path/").isDirectory() -> false
new File("//192.168.10.1/path/").isDirectory() -> false
new File("//192.168.10.2/path/").isDirectory() -> false
new File("//192.168.10.3/path/").isDirectory() -> false
The situation seems even stranger considering what should be "accessible" network-wise from the program using the InetAddress API:
InetAddress.getByName("Server1").isReachable() -> false
InetAddress.getByName("Server2").isReachable() -> true
InetAddress.getByName("Server3").isReachable() -> true
InetAddress.getByName("192.168.10.1").isReachable() -> false
InetAddress.getByName("192.168.10.2").isReachable() -> true
InetAddress.getByName("192.168.10.3").isReachable() -> true
Sort of vague, but has anyone run into any problems like this before?
This topic has been locked.
4 replies Latest Post - 2011-12-14T17:20:59Z by NickWilson
Pinned topic Unable to access network file from Java called from RPG on AS/400
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-12-14T17:20:59Z at 2011-12-14T17:20:59Z by NickWilson
Re: Unable to access network file from Java called from RPG on AS/4002011-12-14T15:53:20Z in response to NickWilsonUpdate:
Turns out the first path tested that return "true" for new File("//Server1/").isDirectory() was a false positive. Turns out that there just happened to be a folder in the IFS on the AS/400 called "//Server1/", so it wasn't actually working correctly to reach Server1.
So, my problem is still that I can't use java.io.File to reach any directory on a different server on the network, and yet some servers are supposedly reachable using InetAddress.isReachable().
Re: Unable to access network file from Java called from RPG on AS/4002011-12-14T15:58:05Z in response to NickWilsonAlso, my co-worker mentioned before that he thought there was a possibility that the AS/400 simply collapses 2 or more slashes together so that File paths are being interpreted as a simple path on the local server, instead of trying to access a resources on a separate server when a path starts with "//".
How can we force the iSeries to access a file on a different server?
Re: Unable to access network file from Java called from RPG on AS/4002011-12-14T17:20:18Z in response to NickWilsonWell, we may have found a reasonable compromise: QNTC. We can use QNTC to access the network resources we care about, but we just have to deal with the requirement that the credentials of the user that's launching the program are valid for accessing the desired network resource. This isn't always the case, but we can probably fix that for our purposes.
Hope that helps someone!