Organizational Research By

Surprising Reserch Topic

how to use spring autowired in a custom cxf interceptor

how to use spring autowired in a custom cxf interceptor  using -'web-services,spring,dependency-injection,cxf'

i seem to run into a small issue when using @Autowired into a custom cxf interceptor.
My use case is that i want to log soap messages and send these using AMQP to another system. This process works for normal services etc.
But whatever i do, the needed properties do not get autowired and stay null.

I checked the Spring DI log and the context is scanned and pickedup, so what am i missing?

Is this even possible in CXF interceptors?

public class LogInInterceptor extends AbstractSoapInterceptor {

    private @Value("#{rabbitMQProperties['rabbitmq.binding.log.soap']}")
    String binding;

    AmqpTemplate amqpTemplate;

    public LogInInterceptor() {

    public void handleMessage(SoapMessage soapMessage) throws Fault {

    private void logIt(SoapMessage message) throws Fault {
        // rest of the code omitted...!!!     
        amqpTemplate.convertAndSend(binding, buffer.toString());



asked Sep 14, 2015 by BradyBurbidg
0 votes

Related Hot Questions

1 Answer

0 votes

You can't mix @InInterceptors (a CXF annotation) and @Component (a Spring annotation). That will create two separate instances of your interceptor: the one whose dependencies are getting injected by Spring, and one created by CXF. (You are providing class names in the @InInterceptors annotation, not a bean ID, so CXF has no way of knowing that you already created an instance in the Spring context.)

Remove the @InInterceptors annotation and, in addition to the component scan:

You also need something like this in your application context:


answered Sep 14, 2015 by YHNRob