javax.ws.rs.ProcessingException: Already connected

GitHub | monksy | 3 years ago
  1. 0

    GitHub comment 7#43124568

    GitHub | 3 years ago | monksy
    javax.ws.rs.ProcessingException: Already connected
  2. 0

    GitHub comment 7#43124568

    GitHub | 3 years ago | monksy
    javax.ws.rs.ProcessingException: Already connected
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Misleading exception is raised once the Jersey client is called once the host with a non-existing, broken or unavailable url is passed in as a parameter for target method. There is no chance to establish connection to such the host but the client is reporting java.lang.IllegalStateException: Already connected instead of rather anticipated UnknownHostException or ConnectException. Example: class DigestRequest { } class DigestResponse { } public class DigestNoLimitClient { public static void main(String[] args) throws Exception { String host = "http://blabla.bla"; Client client = ClientBuilder.newClient(); Entity<DigestRequest> request = Entity.json(new DigestRequest()); Response response = client.target(host).request().post(request); DigestResponse responseObject = response.readEntity(DigestResponse.class); System.out.println(responseObject); } } Result: Exception in thread "main" javax.ws.rs.ProcessingException: Already connected at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:424) at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:333) at net.adamsmolnik.client.DigestNoLimitClient.main(DigestNoLimitClient.java:43) Caused by: java.lang.IllegalStateException: Already connected at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3000) at org.glassfish.jersey.client.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:348) at org.glassfish.jersey.client.HttpUrlConnector.access$100(HttpUrlConnector.java:87) at org.glassfish.jersey.client.HttpUrlConnector$3.getOutputStream(HttpUrlConnector.java:311) at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200) at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194) at org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:262) at org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:811) at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:546) at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:315) at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246) Compare the behavior of code listed above with that showed below: String host = "http://blabla.bla"; HttpURLConnection con = (HttpURLConnection)new URL(host).openConnection(); con.setDoOutput(true); con.getOutputStream().write(1); You get the exception as expected: Exception in thread "main" java.net.UnknownHostException: blabla.bla at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589)

    Java.net JIRA | 2 years ago | adams74
    javax.ws.rs.ProcessingException: Already connected
  5. 0

    Misleading exception is raised once the Jersey client is called once the host with a non-existing, broken or unavailable url is passed in as a parameter for target method. There is no chance to establish connection to such the host but the client is reporting java.lang.IllegalStateException: Already connected instead of rather anticipated UnknownHostException or ConnectException. Example: class DigestRequest { } class DigestResponse { } public class DigestNoLimitClient { public static void main(String[] args) throws Exception { String host = "http://blabla.bla"; Client client = ClientBuilder.newClient(); Entity<DigestRequest> request = Entity.json(new DigestRequest()); Response response = client.target(host).request().post(request); DigestResponse responseObject = response.readEntity(DigestResponse.class); System.out.println(responseObject); } } Result: Exception in thread "main" javax.ws.rs.ProcessingException: Already connected at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:424) at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:333) at net.adamsmolnik.client.DigestNoLimitClient.main(DigestNoLimitClient.java:43) Caused by: java.lang.IllegalStateException: Already connected at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3000) at org.glassfish.jersey.client.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:348) at org.glassfish.jersey.client.HttpUrlConnector.access$100(HttpUrlConnector.java:87) at org.glassfish.jersey.client.HttpUrlConnector$3.getOutputStream(HttpUrlConnector.java:311) at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200) at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194) at org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:262) at org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:811) at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:546) at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:315) at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246) Compare the behavior of code listed above with that showed below: String host = "http://blabla.bla"; HttpURLConnection con = (HttpURLConnection)new URL(host).openConnection(); con.setDoOutput(true); con.getOutputStream().write(1); You get the exception as expected: Exception in thread "main" java.net.UnknownHostException: blabla.bla at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589)

    Java.net JIRA | 2 years ago | adams74
    javax.ws.rs.ProcessingException: Already connected

    6 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Already connected

      at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty()
    2. Java RT
      HttpURLConnection.setRequestProperty
      1. sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3000)
      1 frame
    3. jersey-core-client
      HttpUrlConnector$3.getOutputStream
      1. org.glassfish.jersey.client.HttpUrlConnector.writeOutBoundHeaders(HttpUrlConnector.java:309)
      2. org.glassfish.jersey.client.HttpUrlConnector.access$100(HttpUrlConnector.java:81)
      3. org.glassfish.jersey.client.HttpUrlConnector$3.getOutputStream(HttpUrlConnector.java:283)
      3 frames
    4. Jersey Core
      OutboundMessageContext.commitStream
      1. org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:198)
      2. org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:192)
      3. org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:260)
      4. org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:822)
      4 frames
    5. jersey-core-client
      JerseyInvocation$1.call
      1. org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:451)
      2. org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:287)
      3. org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:200)
      4. org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:215)
      5. org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:634)
      6. org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:631)
      6 frames
    6. Jersey Core
      RequestScope.runInScope
      1. org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      2. org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      3. org.glassfish.jersey.internal.Errors.process(Errors.java:228)
      4. org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:421)
      4 frames
    7. jersey-core-client
      JerseyInvocation$Builder.method
      1. org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:631)
      2. org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:391)
      2 frames
    8. OpenStack4j
      OSFactory.authenticate
      1. org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:77)
      2. org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:42)
      3. org.openstack4j.openstack.OSFactory.authenticate(OSFactory.java:67)
      3 frames
    9. com.avnet.openstackaps
      NovaServiceTest.before
      1. com.avnet.openstackaps.openstackapsintegration.service.OpenstackTemplate.<init>(OpenstackTemplate.java:28)
      2. com.avnet.openstackaps.openstackapsintegration.service.NovaService.<init>(NovaService.java:22)
      3. com.avnet.openstackaps.openstackapsintegration.service.NovaServiceTest.before(NovaServiceTest.java:22)
      3 frames
    10. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:483)
      4 frames
    11. JUnit
      ParentRunner.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      4. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
      5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      13. org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      13 frames
    12. JUnit4 Provider
      JUnit4Provider.invoke
      1. org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
      2. org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
      3. org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
      3 frames
    13. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:483)
      4 frames
    14. SureFire
      ForkedBooter.main
      1. org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
      2. org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
      3. org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
      4. org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
      5. org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
      5 frames