Wed 14 Sep 2005
java.io.FileNotFoundException for valid URL
Posted by Frank Kim under Java SE , ProgrammingNo Comments
In one of our ATG servlet’s we were making a normal HTTP call to a page located on our ATG Dynamo server.
url = new URL(urlString);
connection = (HttpURLConnection)url.openConnection();
reader = new InputStreamReader(connection.getInputStream());
However when trying to get the input stream we got a FileNotFoundException yet we were able to go to the same URL using a browser. Googling around we found this lovely thread about the same problem.
To summarize the thread, the problem was in our proxy settings which are set on Windows in localconfig/environment.bat and on UNIX in localconfig/environment.sh. An example of proxy settings on Windows is set PROXY_ARGS=-Dhttp.proxyHost=192.168.1.134 -Dhttp.proxyPort=8080.
The proxy server did not recognize our machines as valid clients so it rejected our requests. Once we changed the proxyHost argument to point to a valid server then this problem was fixed.