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 - Do not show "No enabled eligible for injection beans are found" for some @Dependent beans.
Summary: Do not show "No enabled eligible for injection beans are found" for some @Dep...
Status: NEW
Alias: None
Product: javaee
Classification: Unclassified
Component: CDI (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-12 10:13 UTC by chrisjr
Modified: 2015-03-12 10:13 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.