How to inject a CDI bean in Apache CXF Interceptor ?

Solution Verified - Updated -

Issue

  • Is it possible to make CDI bean injected in an Apache CXF Interceptor ?

  • We have a demo application, and within which we have a CXF interceptor,

CXF Interceptor:

public class TestServiceInterceptor extends AbstractPhaseInterceptor<Message> {

    @Inject
    Logger logger;

    public TestServiceInterceptor() {
        super(Phase.RECEIVE);

    }

  • In the above, the @Inject is not injecting the required Logger class.

  • However, the same @Inject with Logger is injected and works fine in a JAX-WS handler,

JAX-WS handler:

public class TestServiceHandler implements LogicalHandler<LogicalMessageContext> {

    @Inject Logger logger;

    @Override
    public boolean handleMessage(final LogicalMessageContext context) {
        logger.info("call came handleMessage");
        return true;
    }

Environment

  • Red Hat Enterprise Application Platform (EAP)
    • 6.x
    • 7.x
  • Web Services
    • JBossWS-CXF

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content