wood burning stoves 2.0*
The moose likes Tomcat and the fly likes calling servlet from a java class loaded inside the database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "calling servlet from a java class loaded inside the database." Watch "calling servlet from a java class loaded inside the database." New topic

calling servlet from a java class loaded inside the database.


Joined: Oct 15, 2004
Posts: 3

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");
return "success";

} catch(Exception ex ) {

StringWriter sw = new StringWriter();

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

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

Abdur Rahman.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12758
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)

Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30057

Please don't post the same question in multiple forums.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: calling servlet from a java class loaded inside the database.
Similar Threads
Problems with distributed RMI
calling servlet from a java class loaded inside the database.
JDBC Connection problem
Http through Firewall/Proxy
I can not for the life of me figure out what is causing this