Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling servlet from a java class loaded inside the database.

 
AbdurR
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a java class (source code given below)loaded inside Oracle 9i. The status of the class file is valid in the database. This java class has to call the servlet running on the web server. HTTP being used to connect to the webserver.

At run time I am getting the following error when I try to connect to the web server.

java.net.SocketException: Invalid argument
Invalid argument
at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
at java.net.Socket.<init>(Socket.java:273)
at java.net.Socket.<init>(Socket.java:100)
at sun.net.NetworkClient.doConnect(NetworkClient.java:55)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:335)


The java class loaded inside database is :

import java.net.URL;
import java.net.URLConnection;
import java.io.*;

public class CargoDstMsg {
public static String doCall(int seq_num, int flag) {
try {
String servletURL = "http://" + url1 + ":" + 9099 + "/TestWebApp/SessionServlet" ;

URL url = new URL(servletURL);

URLConnection conn = url.openConnection();

conn.setRequestProperty("obj","Message from Stored Procedure");
conn.connect();
return "success";

} catch(Exception ex ) {

StringWriter sw = new StringWriter();

PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String status = sw.toString();
return status;
}
}
}


If any one knows how to tackle with this exception please do let us know.


Thanks,
Abdur Rahman.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this was my problem I would look at the source code line 320:
at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)

to see what condition would throw that exception. The source code for all java.* packages comes with the SDK in src.zip (or maybe src.jar)

Bill
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abdur,
Please don't post the same question in multiple forums.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic