Editing and validating your context and dependency injection projects

You can use the Context and dependency injection deployment descriptor editor to edit and validate your beans.xml file.

Before you begin

Create a Java EE-faceted project (that is, a utility, EJB, web, connector, or application client project) in your workspace. For information about creating one of these projects see: Creating and configuring Java EE projects using wizards.

About this task

The beans.xml file is required in the packaging and deployment of a CDI-enabled project. The presence of the beans.xml file indicates to the container that the deployed module is a bean archive. The deployment descriptor is generated when you install the CDI facet. See Creating applications that use Contexts and Dependency Injection (CDI). Initially, the beans.xml file is empty, which means that any annotated interceptors, decorators, or alternatives that exist in your module are disabled. To enable these classes, you can configure them using the CDI deployment descriptor editor.

Procedure

  1. To open the context and dependency injection deployment descriptor editor, right-click your beans.xml file and select Open With > Context and Dependency Injection 1.0 Deployment Descriptor Editor.
    CDI deployment descriptor editor
  2. Click Add to add alternatives, decorators, and interceptors to your beans.xml file:
    CDI deployment descriptor editor
  3. The deployment descriptor validates your actions, for example, if you add an empty class to alternatives, an error appears:
    Validation
  4. The deployment descriptor validates your actions, for example, if you add a non-existent class to decorators, an error appears:
    Validation, nonexistent class
  5. The deployment descriptor validates your actions, for example, if you add a class to alternatives that has already been added, an error appears:
    Validation, duplicated class
  6. The deployment descriptor validates your actions, for example, if you specify existing classes that as an alternative, interceptor or decorator class but are not annotated with @Alternative, @Interceptor, or @Decorator respectively an error appears:
    Validation: no annotations

Feedback