• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

No support for FailoverFeature in CXF Rest Client implementation (version 3.1.0)

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had tried some heavy exploration on enabling Failover feature, as per documentation provided by Apache CXF. While the one for SOAP client works like a charm, the other one for REST client is not so with the way I am trying to instantiate the client. My requirement of instantiating the REST client is via JAXRS 2.0.1 API, as shown in following sample code.

NOTE : The following endpoint URL is a valid one, except that the port number has been switched from 8080 (working one) to 8081 (non-working one), since I need to simulate the invocation failure retry behavior.

Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8081/my-app/ws/ers/customers"); Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON_TYPE); Response response = builder.get();

I have found that the Failover feature is not working when the above last line of code is invoked.

Now, here comes the interesting part. I have found only 2 classes in cxf-rt-rs-client-3.1.0-sources.jar where the initialization of Failover feature in a org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean instance happens. And my requirement is to have one of these methods (or, a similar one where bean.setFeatures(features) is invoked ) being called.

Method in org.apache.cxf.jaxrs.client.JAXRSClientFactory class.

public static <T> T create(String baseAddress,
Class<T> cls, List<?> providers,
List<Feature> features,
String configLocation) {

JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation);
return bean.create(cls);
Method in org.apache.cxf.jaxrs.client.WebClient class.

public static WebClient create(String baseAddress,
List<?> providers,
List<? extends Feature> features,
String configLocation) {

JAXRSClientFactoryBean bean = getBean(baseAddress, configLocation);
return bean.createWebClient();
However, when my custom client code above is executed, neither of the above 2 methods have been invoked. Instead, the following method in org.apache.cxf.jaxrs.client.spec.ClientImpl is invoked.

private void initTargetClientIfNeeded() {
URI uri = this.uriBuilder.build(new Object[0]);
if(this.targetClient == null) {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
this.targetClient = bean.createWebClient();
else if(!this.targetClient.getCurrentURI().equals(uri)) {
this.targetClient.to(uri.toString(), false);
Does this imply that Failover Feature is NOT supported for CXF version 3.1.0 ?

If so, which upcoming version of CXF will support my above requirement ?
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!