Jax-ws java.net.ConnectException: Connection refused

大憨熊 提交于 2021-01-28 22:27:03

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5981709/jax-ws-java-net-connectexception-connection-refused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!