0

I'm having this strange error.

On AIX, I can reach my server from the command line ( using ping / telnet )

But If I try using java I've got UnkownHostException

This is because Java cannot somehow "use" the DNS but I don't know why. If I use the IP address it works fine.

This is my test program.

    import java.net.*;

    public class Test {
            public static void main( String [] args ) throws Exception  {
                    String host = args[0];
                    int port = Integer.parseInt( args[1] );
                    System.out.println("Connecting to: " + host + " at port: " + port );
                    Socket socket = new Socket( host, port );
                    System.out.println("Connected!");
                    socket.close();
                    System.out.println("Closed!");

            }
     }

Is anyone aware of some kind of configuration under AIX that forbids programs ( like java ) to access DNS information?

I ( well the sysadm ) have added my address in /etc/hosts but it doesn't work either.

Thanks in advance

Java version:

Java(TM) 2 Runtime Environment, Standard Edition (build pap32dev-20080315 (SR7))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223-20080315 (JIT enabled)
squillman
  • 37,883
  • 12
  • 92
  • 146

3 Answers3

2

Is IPv6 support at fault? Try setting the system property java.net.preferIPv4Stack=true.

See what InetAddress.getAllByName(), InetAddress.getAllByAddress() return.

Allen
  • 1,315
  • 7
  • 12
0

I don't know if Java uses DNS differently, but on AIX if you are going to use the /etc/hosts file, you should make sure /etc/netsvc.conf is set correctly. By default, if /etc/resolv.conf is found, AIX will use DNS, then hosts. To have hosts be first, make sure you have a line in /etc/netsvc.conf that says something like hosts=local,bind4

bobwood
  • 213
  • 1
  • 2
  • 5
0

There are definitely some long term DNS issues with Java and AIX, it's been a while since I've looked at it but try using the fully-qualified domain name rather than a short one.

Also, Java on AIX doesn't seem to use the /etc/hosts file to do name resolutions if /etc/resolv.conf exists, god knows why.

Ewan Leith
  • 1,705
  • 8
  • 7