java.io.FileNotFoundException for valid URL

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());

Free Daddy and His Little Shadow Girls at The Skate Park Creative Commons on FlickrHowever 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.

2 thoughts on “java.io.FileNotFoundException for valid URL

  1. Sir, I am using Windows XP Professional. I wanted to know the location where I can find this environment.bat file, for proxy servers.

    Thank You.
    Akshay Sahu

  2. Hi Akshay,
    The environment.bat file is located wherever ATG is installed. Typically that would be something like C:\ATG\ATG9.1\home\localconfig\environment.bat.
    Hope that helps,
    Frank

Leave a Reply

Your email address will not be published. Required fields are marked *