How to gracefully close an Endpoint when an exception occurs?
问题 I've written a small JAX-WS webservice that I'm running outside a container with Endpoint.publish() : Endpoint endpoint = Endpoint.create(new MyServiceImpl()); endpoint.publish("http://localhost:4425/myService"); If any of my web service methods throws an exception, the endpoint is not gracefully closed and the address remains in use until Windows eventually releases it. This causes the classic error: com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net