Jax-ws java.net.ConnectException: Connection refused
Asked Answered
E

2

2

I'm experiencing an odd networking problem connecting to a web service running on glassfish from a java client running on tomcat using JAX-WS (Metro). Here's the scenario...

  • Both servers are running on my local machine.
  • If I configure the client to connect to the WS endpoint using 127.0.0.1, the request works fine.
  • If I configure the client to connect to the WS endpoint using my IP address, I immediately get java.net.ConnectException: Connection refused. The same thing happens if I use my hostname.

The odd thing is that if I hit the endpoint from SoapUI, the request works fine if use 127.0.0.1, my IP address or my hostname.

Here's the exception I'm getting...

java.net.ConnectException: Connection refused
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:529)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:120)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:256)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:184)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:137)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482)
at com.sun.xml.ws.client.Stub.process(Stub.java:323)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:161)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:113)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144)
at $Proxy51.listAttributeTypes(Unknown Source)
at com.myapp.store.service.client.JaxWsProductAdminServiceClient.listAttributeTypes(JaxWsProductAdminServiceClient.java:71)
at com.myapp.admintool.ProductAttributeController$_closure1.doCall(ProductAttributeController.groovy:26)
at com.myapp.admintool.ProductAttributeController$_closure1.doCall(ProductAttributeController.groovy)
at java.lang.Thread.run(Thread.java:680)

Any thoughts or pointers appreciated!

Emsmus answered 12/5, 2011 at 17:6 Comment(0)
S
2

I have seen a similar problem when running the JAX-WS webservice on a linux box with an entry in /etc/hosts that points the computer's hostname to localhost.

This seems to cause the JAX-WS webservice to be started on http://localhost:port/endpoint and therefore only be accessible from that machine.

Sputter answered 27/10, 2015 at 9:37 Comment(0)
S
0

'Connection refused' means that there is nothing listening at the IP:port you specified. One or both of them is wrong.

Schist answered 13/5, 2011 at 2:3 Comment(4)
Cheers for your comment. I can connect to the endpoint using the IP:Port details I'm providing from Soap UI though so i'm pretty sure they're right - the problem only occurs when connecting using the Java client that is generated from the WSDL.Emsmus
@Jay Shark: is there a firewall in the path that fails? If so it isn't configured with the required ip:port open.Schist
@EJP I have this problem also... What can i do ?Yonita
@AknKplnoglu You can make sure that something is listening at the IP:port you specified. I consider this a rather trivial deduction.Schist

© 2022 - 2024 — McMap. All rights reserved.