Incorrect CDI Injection error?


I think we've found a case where IntelliJ reports an error when there isn't one.

From the Weld documentation: (4.9 Client Proxies, the java type of "classes which don't have a non-private constructor with no parameters" cannot be injected (emphasis mine).
This is common in the case where constructor-injection is used in the injected object's class.

The same Weld link suggests work-around is to introduce an interface, and inject the interface instead.

This deploys and works in Wildfly 8.1.

However, IntelliJ still shows an error in this case by saying, "Injected normal scoped bean is not proxyable". The inspection is "CdiUnproxyableBeanTypesInspection".

Is IntelliJ correct as per the specification, or is this a bug in the CDI inspection?

Minimal example:

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

class A {}

interface IB{}

class B implements IB, Serializable {
@Inject B(A a) {}

class C {
@Inject B b; // IntelliJ shows error but works in Weld

Comment actions Permalink

I have exactly the same question as you. Can the Intellij team answer this?

Comment actions Permalink

I had the same issue, removing static modifiers to the bean's method resolved the warning.


Please sign in to leave a comment.