[jcifs] Workgroup confusion?
Gert van Spijker
gert at ab-graph.com
Fri Jul 22 11:46:35 MDT 2011
I have developed a jcifs based configuration utility for our software
stack that scans the network for available shares and then checks if
certain folders and files exist.
I am testing this on my home network which consists of 3 linux/samba
servers and 4 wxp/w7 workstations divided in 2 workgroups. My scanner
finds both workgroups and all servers on the network but when I try to
query the servers for their shares I get a jcifs.smb.SmbException thrown
on *some* of them.
To make debugging simpler I tried to query the shares in the
examples/ListFiles program, and the same happens:
I debug ListFiles.java from SERVER1 with a command line argument of:
I get the following stack trace:
jcifs.smb.SmbException: Failed to connect: SERVER2<20>/192.168.1.36
java.io.IOException: host unreachable
When I log the related network packets I see that the DNS packet going
out queries a name server2.WORKGROUP2. It gets a "No such name" DNS
response from my router, which is correct because SERVER2 is a member of
WORKGROUP1, not WORKGROUP2!
When stepping into:
I see that Java is calling native code here, so this native code (I am
developing and testing on Ubuntu 11.04 Linux) is apparently responsible
for querying the name with the wrong workgroup suffix. As I mentioned
before, other addresses are handled correctly.
And when I remove (out comment) the call to isReachable() then
everything works as expected! This call seems almost redundant to me
anyway. Why not just try to send the request and let it time out if the
server is not reachable?
The source of this problem is obviously not a bug in jcifs but I wonder
if I am the only one who has seen this happen.
I also invite suggestions as how to avoid this issue other than
modifying the jcifs source code (which is my current solution).
More information about the jCIFS