This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I've got a big problem. I've have an FTP class that opens a connection to a remote machine, that has been used many times and works well in production. However .... I've recently used the FTP component in another application which I need to show to clients, and I get java.net.UnknownHostException when passing an IP address in as the parameter - this works fine on my Win2k dev machine, and the destination IP is that of another Win2k machine. The code fails on a Linux machine (I can however use the account under which the application is run to manually establish a connection to the FTP server as I would expect) Could anyone please suggest where I could start looking for the problem? I am really at a loss. Apologies if this is the wrong forum. Many thanks Andrew
Well, to restate the obvious, the problem is in how Java's doing name resolution on that Linux machine. If you can ftp to the server from that same machine, using the name of the server host, and Java's failing to open a connection, using the same name, exactly (ie., both using FQDN, or neither using FQDN) then obviously they're using separate lookup mechanisms. Try to make sure they're both using exactly the same name. The machine may be oddly configured. This is a little reminiscent of a problem I had years ago on a WinNT using a telco-return cable modem; Java and C programs generally disagreed about what the local host's IP address was. Java was clearly using a different resolution mechanism. Well, sorry, I'm rambling. You wanted ideas for things to poke around in. Have a look in the /etc/hosts file to see if the server host's address is hard-coded there. Also look at /etc/resolv.conf to see what the machine is using for a nameserver(s). Use dig or nslookup to lookup the server both by FQDN and by hostname alone (if this is a LAN situation), and see what you get.
Thanks, I probably wasn't 100% clear - but I'm using the IP address, which shouldn't need to be resolved! Therefore I'm thinking more along the lines of security or the context in which the application is running. Regards Andrew
Joined: Aug 13, 2003
OK I solved this - I simply needed to .trim() the ip address that I obtained from the database. This extra white space seemed to be ignored on Win2k, but not on Linux.... Cheers Andrew