File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
Author

calling servlet from a java class loaded inside the database.

AbdurR
Greenhorn

Joined: Oct 15, 2004
Posts: 3
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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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

Joined: May 26, 2003
Posts: 31067
    
232

Abdur,
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling servlet from a java class loaded inside the database.