rahu_webdev
01-19-2005, 01:18 PM
Hi All
I'm facing a very Strange Exception in my java code.
The java file is making an HTTP connection with a remote server running on the Tomcat (server has same configuration as that on my machine...). My application sends a request in XML file to this server and receives the response in the XML file .
Now the problem is that the first two request are processed by the server correctly....but on the third request it gives the Exception:-
java.io.FileNotFoundException: <server-url>
The source of the errror is from this piece of code ==>
path = Config.getServerLocation(serviceId); // This gets the URL of the server
URL url = new java.net.URL(path);
con = (HttpURLConnection) url.openConnection();
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/xml");
OutputStream os = con.getOutputStream();
os.write(xml.getBytes());
con.connect();
int code = con.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
InputStream is = con.getInputStream(); //This InputStream 'is' is the response from the server
return XMLHelper.loadXML(is);
}
The stackTrace says that the Exception is thrown from the getResponseCode() which is due to the exception thrown by the HttpURLConnection.java class's method getInputStream()
Is it a BUG in the HttpURLConnection.java for JDK1.3 ???? OR
Am I making some mistake ???
The environment I'm using to comile the code is JDK1.3
& the server is deployed on Tomcat 4.0.6 .
I'm facing a very Strange Exception in my java code.
The java file is making an HTTP connection with a remote server running on the Tomcat (server has same configuration as that on my machine...). My application sends a request in XML file to this server and receives the response in the XML file .
Now the problem is that the first two request are processed by the server correctly....but on the third request it gives the Exception:-
java.io.FileNotFoundException: <server-url>
The source of the errror is from this piece of code ==>
path = Config.getServerLocation(serviceId); // This gets the URL of the server
URL url = new java.net.URL(path);
con = (HttpURLConnection) url.openConnection();
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/xml");
OutputStream os = con.getOutputStream();
os.write(xml.getBytes());
con.connect();
int code = con.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
InputStream is = con.getInputStream(); //This InputStream 'is' is the response from the server
return XMLHelper.loadXML(is);
}
The stackTrace says that the Exception is thrown from the getResponseCode() which is due to the exception thrown by the HttpURLConnection.java class's method getInputStream()
Is it a BUG in the HttpURLConnection.java for JDK1.3 ???? OR
Am I making some mistake ???
The environment I'm using to comile the code is JDK1.3
& the server is deployed on Tomcat 4.0.6 .