How can I configure JBoss EAP 7 RESTeasy client to follow redirect?

Solution In Progress - Updated -

Issue

We are using a REST client that needs to resolve redirections. In JBoss EAP 6 with RESTEasy client API ClientRequest class we had the method request.followRedirects(true). So we're able to write the following to configure the client to follow redirects:

 ClientResponse<String> response = request.followRedirects(true).get(String.class);

Now when using the JAX-RS client for JBoss EAP 7.0.x and we don't see an equivalent method when creating the client using the following code:

client.target(...).queryParam(...).request().accept(MediaType.APPLICATION_JSON)......

If we don't set follow redirects an exception is thrown when the server response is 3XX HTTP codes:

Exception in thread "main" javax.ws.rs.RedirectionException: HTTP 301 Moved Permanently
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:168)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:479)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.get(ClientInvocationBuilder.java:165)
    at org.example.resteasy.FollowRedirectTests.doRequest(FollowRedirectTests.java:43)
    at org.example.resteasy.FollowRedirectTests.testWithoutFollowRedirect(FollowRedirectTests.java:27)
    at org.example.resteasy.FollowRedirectTests.main(FollowRedirectTests.java:23)

What can be done to configure our REST client to follow redirects?

Environment

  • Red Hat JBoss Application Platform (EAP)
    • 7.0.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.