[jcifs] Cannot assign requested address

Mathias Dietz MDIETZ at de.ibm.com
Wed Aug 10 15:39:06 GMT 2005


with jcifs 1.2.1 I get the following error message when I try to connect to
a samba share. (using fedora core 4 and java 1.5)
jcifs.util.transport.TransportException
java.net.SocketException: Invalid argument or cannot assign requested
address
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      ......
      at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:228)
      at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:266)
      at jcifs.util.transport.Transport.run(Transport.java:204)
      at java.lang.Thread.run(Thread.java:568)

After some testing and debugging I found that the problem does not occur
with jcifs 1.1.11.
With jcifs 1.2.1 the config class has been changed to the following:

    public static InetAddress getLocalHost() {
        String addr = prp.getProperty( "jcifs.smb.client.laddr" );
        try {
            if( addr == null ) {
  --->>>            return InetAddress.getLocalHost();     <<<----
            }
            return InetAddress.getByName( addr );
        } catch( UnknownHostException uhe ) {
            if( log.level > 0 ) {
                log.println( addr );
                uhe.printStackTrace( log );
        }   }
        return null;
    }

If no jcifs.smb.client.laddr is specified, then localhost/127.0.0.1 is
returned and
SMBTransport uses the returned value to create a socket.
 ->>  socket = new Socket( address.getHostAddress(), port, localAddr,
localPort );

This is not possible because the samba server is not reachable via
127.0.0.1 (NoRouteToHost!).

Could someone fix this bug ? Possible solutions:
      A) change the Config.getLocalHost() method to return null if no
jcifs.smb.client.laddr is specified
      B) change SMBTransport and replace LADDR with Config.getInetAddress(
"jcifs.smb.client.laddr", null )  (jcifs 1.1.11 like)

Question: Where is the most current JCIFS version ? Does a CVS or SVN
repository exist ?


mit freundlichen Grüßen / best regards

Mathias Dietz

------------------------------------------------------------------------
Software Development                              Dept. A182
IBM Deutschland GmbH
Hechtsheimer Strasse 2  Geb.83
D-55131 Mainz
Phone (+49)-6131-84-2027
Fax (+49)-6131-84-3111
E-Mail : MDietz at de.ibm.com
IBM Certified Professional Server Specialist
------------------------------------------------------------------------
Visit Open Enterprise System Virtualization:
IBM intranet ---> http://w3.ais.mainz.de.ibm.com/stonehenge/






More information about the jcifs mailing list