Search code examples
jax-rscdiquarkus

Quarkus 2.5: @Inject inside JAX-RS Application subclass not working anymore


After upgrading Quarkus from 1.6.1.Final to 2.5.Final the following @Inject fails inside javax.ws.rs.core.Application subclass:

@ApplicationScoped
public class MyBean {

    public String foo() {
        retun "bar";
    }
}
@ApplicationPath("/")
public class MyApplication extends Application {

    @Inject
    MyBean myBean;

    @Override
    public Set<Class<?>> getClasses() {
        myBean.foo(); // Causes NPE on Quarkus 2.5.Final, worked well with 1.6.1.Final
    
    }
}

I tried with CDI.current().select(MyBean.class).get() but got Unable to locate CDIProvider.

Any other workaround I can try? Thanks.


Solution

  • @Inject in JAX-RS Application classes has been since disallowed. I was able to solve my issue (registering resource classes by config) using @IfBuildProperty annotation.