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 https://docs.jboss.org/weld/reference/2.1.2.Final/en-US/html_single/#d0e1464), 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; import java.io.Serializable; class A {} interface IB{} @ApplicationScoped class B implements IB, Serializable { @Inject B(A a) {} } class C { @Inject B b; // IntelliJ shows error but works in Weld }
请先登录再写评论。
I have exactly the same question as you. Can the Intellij team answer this?
Hello,
Please follow the issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-188142
I had the same issue, removing static modifiers to the bean's method resolved the warning.
I have the same issue.
I don't find the answer although this one is marked as answered.
Please comment inside the bug request https://youtrack.jetbrains.com/issue/IDEA-188142 with exact steps to reproduce, screenshot, and a sample project attached.
We could not reproduce it on our side yet.
Hi there, I have added a comment, https://youtrack.jetbrains.com/issue/IDEA-188142#focus=Comments-27-5764840.0-0