java.net.UnknownHostException - intermittant issues
<p>I have a Web Service written in Java using Java 1.6.0_17.<br>
One of the services goes out and screen scraps another one of my servers using the following code:</p>

<pre><code>HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();

InputStream stream = connection.getInputStream();

return convertStreamToString(stream);
</code></pre>

<p>For the most part, about 80% of the time (very rough guess) this seems to work fine however the rest of the time I am getting the following exception when I get to the connection.connect() part of the code:</p>

<pre><code>java.net.UnknownHostException: {my server name was here}
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
</code></pre>

<p>I replaced the URL of our server with {my server name was here} in the logs above.
I am able to run nslookup and the server resolves fine.</p>

<p>The Web Service runs on a JBoss 4.2.3 server on a Windows 2003 Standard x64 Edition Service Pack 2 server.</p>

<p>I do know that the Unknownhost exception means the server name could not be resolved, however I am struggling with why this is happening intermittently.
I would prefer to not resolve the host name via the host file because in the future, when we change hosts, I would like to be able to change the DNS and not worry about the host files.<br>
Does anyone have any suggestions on how to resolve this issue? 
Thank you in advance for any help you can provide.</p>
