[jcifs] Re: NullPointerException in NbtAddress.java

Michael B Allen mba2000 at ioplex.com
Thu Feb 17 00:37:36 GMT 2005


Your network is misconfigured. InetAddress.getLocalHost() should not throw
an exception. Look at the FAQ. The stuff about the hosts file might be
pertinent.

Mike

Alan Moore said:
> Mike,
>
> I couldn't figure out how to subscribe to the jcifs mailing list (link is
> broken) so I saw your name in the archives and hoped you could help me
> out.
>
> It seems that NbtAddress has a bug here - see comments with KAM:
>
> localInetAddress = CLIENT.laddr; // KAM - null by default
>
> if( localInetAddress == null ) {
>
> try {
>
>    localInetAddress = InetAddress.getLocalHost();
>
> } catch( UnknownHostException uhe ) { // KAM - thrown by InetAddress when
> linux is configured as static IP
>
> }
>
> }
>
> localHostname = Config.getProperty( "jcifs.netbios.hostname", null );
>
> if( localHostname == null || localHostname.length() == 0 ) {
>
> byte[] addr = localInetAddress.getAddress(); // KAM - if UHE thrown above,
> localInetAddress is null here
>
>                                              // KAM - resulting in a
> NullPointerException
>
>
>
> I personally believe that InetAddress.getLocalHost() shouldn't throw an
> UnknownHostException, but it does... In any case, NbtAddress should not
> throw a NPE.
>
> I tried setting the config for jcifs.netbios.laddr=127.0.0.1 to avoid the
> UHE/NPE but now all my reverse name lookups are failing (e.g. calling
> UniAddress.getByName(ipAddressString).getHostName() throws UHE.)
>
> Let me know how I can help.
>
> alan
> __________________
> Bleib immer locker
>



More information about the jcifs mailing list