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 178687 - CDI beans names not listed in autocomplete window
Summary: CDI beans names not listed in autocomplete window
Alias: None
Product: javaee
Classification: Unclassified
Component: JSF Editor (show other bugs)
Version: 6.x
Hardware: All Windows 7 x64
: P2 normal with 4 votes (vote)
Assignee: Marek Fukala
Depends on:
Reported: 2009-12-15 17:28 UTC by GeraldoLuiz
Modified: 2010-02-08 19:14 UTC (History)
8 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description GeraldoLuiz 2009-12-15 17:28:12 UTC
NetBeans 6.8: In a .xhtml file (facelets), the autocomplete assist feature (Ctrl-Space) is not listing the names of CDI (Weld) beans defined in the application.

If I create a bean with @Named annotation, it doesn't show up in the list when I press Ctrl-Space inside an EL expression: "#{}" in xhtml file.

If I use @ManagedBean annotation instead, the bean name appears in the list and I can search its methods, but not with @Named annotation.

As an example, to reproduce the behavior, just create a Web project on NetBeans 6.8, using JSF2 and facelets, named testApp. Then, create a new java class, say 'TestClass' in 'my' package:

package my;

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

public class TestClass implements Serializable {

    private static final long serialVersionUID = 1L;

    private String str;

    public String getStr() {
        return str;

    public void setStr(String str) {
        this.str = str;

    public String clicked() {
        System.out.println("Button clicked");
        return null;

Decorate the class with @Named and @SessionScoped annotations, create a private String field named 'str', getter and setter, and a public method named 'clicked', for the button click action. The CDI bean is ready to go.

I'm not defining a name for the bean so a standard one is used, that is the name of the class with the first letter in lower case, in this case, 'testClass'.

Now put some code in 'index.xhtml' to interact with the bean.

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""
        <title>Facelet Title</title>
            <h:inputText value="#{testClass.str}"/>
            <h:commandButton value="Click me!" action="#{testClass.clicked}"/>

Finally, create an empty file in the WEB-INF folder named 'beans.xml' to trigger the CDI service.

The app works as expected. The problem is, when I type <h:inputText value="#{}"/> in index.xhtml, NetBeans shows a list of components that can be used for this EL expression, but no CDI bean is included on the list.
Comment 1 GeraldoLuiz 2009-12-17 03:48:01 UTC
The JSR-299 Context and Dependency Injection (CDI) is part of Java EE 6 Specification so its features should be integrated into netbeans autocomplete and code assist system.
Comment 2 cayhorstmann 2009-12-19 07:36:27 UTC
This is actually pretty important because there is a strong sentiment by some in the JSF expert group that @Named should be preferred to @ManagedBean in most cases. It would be a shame if people got lured into @ManagedBean just because of the IDE support.
Comment 3 David Konecny 2009-12-20 16:11:37 UTC
This is serious deficiency which needs to be amended ASAP.
Comment 4 David Konecny 2009-12-22 13:22:04 UTC
For now I'm assigning it to you Denis.
Comment 5 Denis Anisimov 2010-01-11 04:42:58 UTC
I have added API methods into Web Beans model which allow to get Java Elements
with @Named annotation.
Also there is a method which returns "named" value .

So I reassign this issue into JSF area.
Comment 6 justinwyer 2010-01-12 03:42:42 UTC
It would also need to resolve elements (methods or fields) which are annotated with @Produces as these can also be used within EL expressions.
Comment 7 justinwyer 2010-01-12 04:06:04 UTC
(In reply to comment #6)
> It would also need to resolve elements (methods or fields) which are annotated
> with @Produces as these can also be used within EL expressions.

Ignore this, the @Named annotation would be required in addition to @Produces in this case.
Comment 8 Marek Fukala 2010-01-13 07:43:39 UTC
should be fixed in web-main#826629b831a0

As for the CDI support module, there used to be no public packages exposed, so supposing this wasn't intentional, I exposed the api package as fried to the web.jsf.editor module. I know wery little of what are the plans for this module regarding the api level, so whoever is involved, please review and possibly take appropriate actions.

By the way, I must do emphasize that the EL support code is a mess and needs to be redone from scratch. The fix is made with respect to this fact.
Comment 9 Quality Engineering 2010-01-14 23:38:38 UTC
Integrated into 'main-golden', will be available in build *201001150201* on (upload may still be in progress)
User: Marek Fukala <>
Log: #178687 -  CDI beans names not listed in autocomplete window
Comment 10 Marek Fukala 2010-01-15 02:13:06 UTC
Additional important fix which needs to be put into the patch as well!

web-main#56083e99ed95 - proper handling of web beans names.
Comment 11 Jindrich Sedek 2010-01-18 08:20:54 UTC
100118-a10216e72f6c (web-main)
Comment 12 Quality Engineering 2010-01-18 23:35:21 UTC
Integrated into 'main-golden', will be available in build *201001190201* on (upload may still be in progress)
User: Marek Fukala <>
Log: #178687  - additional fix: proper handling of web beans names
Comment 13 pgebauer 2010-01-20 13:24:16 UTC
The changeset uses the method WebBeansModel.getNamedElements(). The mentioned method has been introduced by following the changeset however a "simple" port doesn't work because a new implementaion of WebBeansModelProvider is needed.

Could you please provide a changeset for the method WebBeansModel.getNamedElements() and its implementation applicable in the release68_fixes branch?
Comment 14 pgebauer 2010-01-22 03:58:17 UTC
The fix has been ported into the release68_fixes repository.

The fix has been ported together with the bugfix of issue #179629. If a rollback is needed, both issues have to be skipped together. Since the port is non-trivial (please see the changeset), please consider wider and deeper testing.
Comment 15 Jindrich Sedek 2010-01-27 05:40:51 UTC
verified in 68_fixes build
NetBeans IDE 6.8 (Build 201001261800)
Comment 16 GeraldoLuiz 2010-02-06 08:25:11 UTC
Thanks for this enhancement. 

Netbeans is, without any dounbt, the best IDE around, and it gets even better with this theese quick responses to the community requests.

Comment 17 David Konecny 2010-02-08 19:14:13 UTC
Thanks for the words of support Geraldo! It is always good to get a feedback and even better if it is positive one. :-)

FYI: lists new CDI features.