This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 251126

Summary: Do not show "No enabled eligible for injection beans are found" for some @Dependent beans.
Product: javaee Reporter: chrisjr
Component: CDIAssignee: Sergey Petrov <sj-nb>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.0.2   
Hardware: PC   
OS: Windows 7 x64   
Issue Type: DEFECT Exception Reporter:

Description chrisjr 2015-03-12 10:13:13 UTC
The following bean is completely legal in CDI:

@Dependent
public class TestBean {

    private final OtherBean other;

    @Inject
    public TestBean(OtherBean other) {
        this.other = other;
    }

    public void doThings() {
        // ... etc
    }

}

But when I try to inject it into something:

    @Inject
    private TestBean testBean;

NetBeans refuses to accept TestBean as an injectable bean unless TestBean also has a no-args constructor. The IDE shows the following warning:

"No enabled eligible for injection beans are found".

NetBeans is incorrect here because TestBean has @Dependent scope (i.e. it's a POJO) and so does not need to have a no-args constructor so long as it still has a constructor annotated with @Inject.

See: http://docs.jboss.org/weld/reference/latest/en-US/html/intro.html#_what_is_a_bean

"But wait! TextTranslator does not have a constructor with no parameters! Is it still a bean? If you remember, a class that does not have a constructor with no parameters can still be a bean if it has a constructor annotated @Inject."

WELD does not require TestBean to have a no-args constructor either, of course: my test application boots and runs just fine. Only NetBeans has a problem here.