jersey
  1. jersey
  2. JERSEY-1790

Change in API causing failure in GlassFish after last integration

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-m13
    • Fix Version/s: 2.0-rc1, 2.0
    • Component/s: None
    • Labels:
      None

      Description

      The last jersey integration in GlassFish broke some existing code.

      the old code that worked:

      Client client = ClientBuilder.newClient();
      //at some point need to get credentials from service object
      String username = "admin";
      String password = "";
      String host = "localhost";
      String port = service.getServiceProperties().get("admin_port");
      client.register(new HttpBasicAuthFilter(username, password));
      String url = "http://"host":"port"/management/domain/enable-monitoring";
      WebTarget target = client.target(url);

      now gives the following exception.

      java.lang.IllegalStateException: Error initializing key manager factory (unrecoverable key).
      at org.glassfish.jersey.SslConfigurator.createSSLContext(SslConfigurator.java:648)
      at org.glassfish.jersey.SslConfigurator.getDefaultContext(SslConfigurator.java:277)
      at org.glassfish.jersey.client.JerseyClientBuilder.build(JerseyClientBuilder.java:126)
      at org.glassfish.jersey.client.JerseyClientBuilder.build(JerseyClientBuilder.java:59)
      at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114)

        Issue Links

          Activity

          Hide
          kumara added a comment -

          Is the server at http://host:port issuing a redirect to https? The stack trace indicates an error in configuring SSL. Is it possible to specify a SSL context (JerseyClientBuilder.sslContext()) or configure standard JSSE using javax.net.keystore.* and javax.net.truststore.* properties?

          Show
          kumara added a comment - Is the server at http://host:port issuing a redirect to https? The stack trace indicates an error in configuring SSL. Is it possible to specify a SSL context (JerseyClientBuilder.sslContext()) or configure standard JSSE using javax.net.keystore.* and javax.net.truststore.* properties?
          Hide
          Michal Gajdos added a comment -

          Are there any javax.net.ssl.* properties defined in system properties? If so JerseyClientBuilder tries to resolve a SSLContext from them and use it for requests.

          Can you try creating client like

          ClientBuilder.newBuilder().sslContext(SslConfigurator.newInstance(false).createSSLContext()).build();
          

          to see if the problem persists? (SslConfigurator.newInstance(false) should disable configuring the SSLContext from system properties)

          Show
          Michal Gajdos added a comment - Are there any javax.net.ssl.* properties defined in system properties? If so JerseyClientBuilder tries to resolve a SSLContext from them and use it for requests. Can you try creating client like ClientBuilder.newBuilder().sslContext(SslConfigurator.newInstance( false ).createSSLContext()).build(); to see if the problem persists? ( SslConfigurator.newInstance(false) should disable configuring the SSLContext from system properties)
          Hide
          peter_pilgrim added a comment -

          This is causing still on GlassFish 4.0-b81 still.

          java.lang.IllegalStateException: Error initializing key manager factory (unrecoverable key).
          at org.glassfish.jersey.SslConfigurator.createSSLContext(SslConfigurator.java:648)
          at org.glassfish.jersey.SslConfigurator.getDefaultContext(SslConfigurator.java:277)
          at org.glassfish.jersey.client.JerseyClientBuilder.build(JerseyClientBuilder.java:126)
          at org.glassfish.jersey.client.JerseyClientBuilder.build(JerseyClientBuilder.java:59)
          at uk.co.xenonique.devoxxuk13.demo.RestfulBookServiceTest.shouldRetrieveListOfBooksAsPlainText(RestfulBookServiceTest.java:52)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
          at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)

          @RunWith(Arquillian.class)
          public class RestfulBookServiceTest {

          @ArquillianResource
          private URL baseURL;

          @Deployment(testable = false)
          public static WebArchive createDeployment()

          { WebArchive webArchive = ShrinkWrap.create(WebArchive.class) .addClasses(RestfulBookService.class) .addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml"); System.out.println(webArchive.toString()); return webArchive; }

          @Test
          public void shouldRetrieveListOfBooksAsPlainText()

          { URI uri = URI.create( (baseURL.toExternalForm()+"great/books" ) ); System.out.printf("uri=%s\n", uri ) ; Client client = ClientBuilder.newBuilder().build(); WebTarget target = client.target(uri.toString()); Response response = target.request().get(); System.out.printf("response=%s", response); assertEquals(200, response.getStatus()); assertTrue( response.getLength() > 0); System.out.printf(response.toString()); }

          }

          Show
          peter_pilgrim added a comment - This is causing still on GlassFish 4.0-b81 still. java.lang.IllegalStateException: Error initializing key manager factory (unrecoverable key). at org.glassfish.jersey.SslConfigurator.createSSLContext(SslConfigurator.java:648) at org.glassfish.jersey.SslConfigurator.getDefaultContext(SslConfigurator.java:277) at org.glassfish.jersey.client.JerseyClientBuilder.build(JerseyClientBuilder.java:126) at org.glassfish.jersey.client.JerseyClientBuilder.build(JerseyClientBuilder.java:59) at uk.co.xenonique.devoxxuk13.demo.RestfulBookServiceTest.shouldRetrieveListOfBooksAsPlainText(RestfulBookServiceTest.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) @RunWith(Arquillian.class) public class RestfulBookServiceTest { @ArquillianResource private URL baseURL; @Deployment(testable = false) public static WebArchive createDeployment() { WebArchive webArchive = ShrinkWrap.create(WebArchive.class) .addClasses(RestfulBookService.class) .addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml"); System.out.println(webArchive.toString()); return webArchive; } @Test public void shouldRetrieveListOfBooksAsPlainText() { URI uri = URI.create( (baseURL.toExternalForm()+"great/books" ) ); System.out.printf("uri=%s\n", uri ) ; Client client = ClientBuilder.newBuilder().build(); WebTarget target = client.target(uri.toString()); Response response = target.request().get(); System.out.printf("response=%s", response); assertEquals(200, response.getStatus()); assertTrue( response.getLength() > 0); System.out.printf(response.toString()); } }

            People

            • Assignee:
              Marek Potociar
              Reporter:
              carlavmott
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 30 minutes
                4h 30m