You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gabor Dolla <ag...@gmail.com> on 2019/12/30 14:59:38 UTC

cxf with JdkDynamicAopProxy

Hi

I use:
java: 13
Spring Boot 2.2.2

org.apache.cxf:cxf-spring-boot-starter-jaxws:3.3.4

org.apache.cxf:cxf-rt-features-clustering:3.3.4


My CXF client is defined as a Spring bean:

@Bean
public MyService createMyServiceClient(JaxWsProxyFactoryBean
jaxWsProxyFactoryBean) {
  MyService service = (MyService) jaxWsProxyFactoryBean.create();

  Client client = ClientProxy.getClient(service);
  client.getBus().getOutInterceptors().add(new HeaderInterceptor());
  return service;
}

elsewhere I have it injected and use it like this:

@Autowired
private MyService myService;

private void aMethod() {

  Client client = ClientProxy.getClient(myService);
  client.getRequestContext().put("messageId", messageId);

  myService.myMethod();

}


I need to put the messageId into the request context so that the
HeaderInterceptor can

put the value into the http request header.


Everything works just great, now I'd like to use Spring Cloud Config
so that I could change

the url of the remote server on the fly.


In order to use this feature I needed to add @RefreshScope to my bean
definition which creates a proxy object.

With this configuration I receive this exception:

java.lang.ClassCastException: class
org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to
class org.apache.cxf.frontend.ClientProxy

When my code tries to get the client in order to set the message id, it fails.

If I remove this bit, everything just works and I can change the url
without restart

but the messageId is missing from the http header which unfortunatelly
is not optional.


Any idea ? Thanks in advance


Gabor