问题
I am trying to dockerize a jersey application which acts both as a REST server and client. The application seems to behave differently when running inside a docker container.
I am able to perform a request to a non-dockerized service (A). The problem occurs when I try to perform a request on another non-dockerized REST server (B), using, in both cases, JAX-RS client API:
// common code - for contacting both A & B services
private static final Client client = ClientBuilder.newClient().register(JacksonFeature.class);
// inside the method called for each request
WebTarget target = client.target(location);
// for each query param : target = target.queryParam(..);
logger.info("This is logged successfully");
Response resp = target.request(MediaType.APPLICATION_JSON_TYPE).method(method, Entity.json(payloadBean));
logger.info("This is NOT logged for B service");
At this point I am getting a javax.ws.rs.ProcessingException: Already connected
... Caused by: java.lang.IllegalStateException: Already connected
I use a single Dockerfile where I set up oracle-java-8 and (Tomcat or Jetty), in the exact same way I did on the host before docker where everything works fine!
There is no SSL involved for sure.
Running my app on the same VM with B service produces the same behavior.
Service A is jersey, while B is django, but that shouldn't be relative to the problem since they are both REST services.
Any idea on how I could debug this situation?
回答1:
I am sorry for the spam, as it turned out it was a very stupid mistake:
service A location was an IP address
service B location was an uknown dns name to the container
Thus passing --add-host B_fqdn:B_internal_IP
to docker run
solved the issue
来源:https://stackoverflow.com/questions/36622484/already-connected-exception-when-running-jersey-application-inside-docker-cont