This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • 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 ="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 = Object[0]);
if(this.targetClient == null) {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
this.targetClient = bean.createWebClient();
else if(!this.targetClient.getCurrentURI().equals(uri)) {, 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 ?
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!