• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with URLConnection

 
Jerry Crone
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting an exception when I use a HttpURLConnection connected to a
servlet.I have not seen an error in the server logs on Oracle 9i AS. When I execute the code in JDeveloper(as client) or DOS CMD window,there is no exception. The exception also occurs when I use Java Plug-in: version 1.4.0_04. OS= Win 2000 browser = InternetExplorer
Java(TM) Plug-in: Version 1.3.1_02
Using JRE version 1.3.1_02 Java HotSpot(TM) Client VM
Proxy Configuration: no proxy
----------------------------------------------------
jcrone,INFO,Applet starting: user->jcrone ; district->All ; log level->INFO
jcrone,INFO,canEstConn:to DBserv:http://<server ort>/invchg/dbsrv?user=jcrone&task=canEstConn&data=
jcrone,INFO,ldRIC:to DBserv:http://<server ort>/invchg/dbsrv?user=jcrone&task=ldRIC&data= <OK>
jcrone,INFO,ldIC:to DBserv:http://<server ort>/invchg/dbsrv?user=jcrone&task=ldIC&data= <error>
jcrone,ERROR,ICDBWebAdapter: loadIC: exception:Connection failure with 500
java.io.IOException: Connection failure with 500
at sun.plugin.protocol.jdk12.http.HttpURLConnection.getInputStream(Unknown Source)
at RPInvChange.InvChgDBWebAdapter.loadInventoryChanges(InvChgDBWebAdapter.java:241)
at RPInvChange.RPInvChgModel.<init>(RPInvChgModel.java:103)
at RPInvChange.RPICMain.jbInit(RPICMain.java:537)
at RPInvChange.RPICMain.init(RPICMain.java:487)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Note: there is no 'data' for these services; i.e., no data is needed
CODE
----
public static final String USER_GET = "?user=";
StringBuffer inBuff;
BufferedReader in;
URLConnection conn;
String answer;
ArrayList invChgGroups = new ArrayList();
public ArrayList loadInventoryChanges() {
try {
String getURL = dbURL + USER_GET + userID + "&task=ldIC&data=";
URL url = new URL(getURL);
conn = url.openConnection();
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setDefaultUseCaches(false);

in = new BufferedReader(new InputStreamReader(conn.getInputStream())); // 241
inBuff = new StringBuffer();
while((line = in.readLine()) != null) {
inBuff.append(line);
}
answer = inBuff.toString();
handlerCoIC = new InvChgCollXMLHandler(this);
handlerCoIC.setParser(handlerCoIC.newParser("false"));
handlerCoIC.parse(answer); // populates invChgGroups

return invChgGroups;
}
catch (Exception e) {
Logger.log(Logger.ERROR, userID, "ICDBWebAdapter: loadIC: exception:"
+ e.getMessage());
e.printStackTrace(System.out);
}
finally {
try {
if(in != null){
in.close();
in = null;
};
((HttpURLConnection)conn).disconnect();
conn = null;
}
catch (Exception e2) {
System.out.println("problem closing HTTP connection");
System.out.println(e2.getMessage());
}
}
return new ArrayList();
}
 
Jerry Crone
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the XML parsing is commented out, there are no exceptions. So, the parser is setting something that messes up the servlet, I think.
 
Jerry Crone
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The program is working now. I added "Thread.sleep(20000);" as the first line. There must be some sort of race condition, possibly XML classes being instantiated.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!