aspose file tools*
The moose likes Java in General and the fly likes Connection refused on localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Connection refused on localhost" Watch "Connection refused on localhost" New topic
Author

Connection refused on localhost

Rudolf Lomniczi
Greenhorn

Joined: Nov 02, 2010
Posts: 3
Hi,

I faced an annoying and strange problem, I have no more idea how to solve it.
Problem: It's is a very simple situation. An Apache Tomcat runs on my machine, it listens on 8081 port. I want to acces this URL hosted by Tomcat from Java:

http://localhost:8081/archeo/services/AdminService?wsdl

The sample code:




But it doesn't work, neither from Eclipse nor java command line. I get the following exception:

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.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:975)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:916)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1177)
at com.ind.bb.tools.URLTest.main(URLTest.java:31)

I can access this URL from any browsers. No http proxy set. Tomcat is running:

D:\programs\apache-tomcat-5.5.31\bin>netstat -a | grep 8081
TCP [::]:8081 INDNOTE2:0 LISTENING

Java version is jdk1.6.0_22, OS is Windows 7. I tried this URL's too:

http://127.0.0.1:8081/archeo/servlet/AxisServlet

Could somebody help me?
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
I'm confused. You say that you want to access:

http://localhost:8081/archeo/services/AdminService?wsdl

But then you try in your code:

http://127.0.0.1:8081/archeo/servlet/AxisServlet

Then at the bottom of your post, you say you tried:

http://127.0.0.1:8081/archeo/servlet/AxisServlet

But don't say where you tried it or whether it succeeded.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Windows 7, is it? Then perhaps there's an internal firewall entry preventing anything from connecting to that port.

You could try the Telnet test: go to a command line screen and do this:

Rudolf Lomniczi
Greenhorn

Joined: Nov 02, 2010
Posts: 3
Dear Tom,

Sry, I did not write enough information about call http://127.0.0.1:8081/archeo/servlet/AxisServlet url. The answer: none of URLs were successful.

Dear Paul,

I tried telnet formerly and it was successful.


But problem has been solved yesterday: I used wrong Tomcat version: I had to use 6.x instead of 5.5.31. I don't know what is the real cause, but Tomcat 6.x works fine.

Thanks for help!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Rudolf Lomniczi wrote:Sry

Sorry to nitpick, but UseRealWords: sorry.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rudolf Lomniczi
Greenhorn

Joined: Nov 02, 2010
Posts: 3
All right, no problem I'll follow it. I'm a new user.
 
Consider Paul's rocket mass heater.
 
subject: Connection refused on localhost