tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien PRUNIER <sebastien.prun...@gmail.com>
Subject java.net.ConnectException when attempting to open URL via Java code
Date Mon, 23 Aug 2010 13:09:12 GMT
The following piece of code generates a "java.net.ConnectException: Connection
refused: connect" error :

URL url = new URL("http://localhost:8080/myapp/mypage.jsp");
url.openStream();

It crashes with Tomcat 5.5.30 but it works with Tomcat 5.5.28.

The Tomcat server is started and the HTTP link works in my web browser.

The full error stack is :
Exception in thread "main" java.net.ConnectException: Connection refused:
connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.Socket.connect(Socket.java:524)
    at java.net.Socket.connect(Socket.java:474)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
    at sun.net.www.http.HttpClient.New(HttpClient.java:304)
    at sun.net.www.http.HttpClient.New(HttpClient.java:321)
    at
sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:839)
    at
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:791)
    at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:716)
    at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:960)
    at java.net.URL.openStream(URL.java:1007)
    at Main.main(Main.java:11)

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message