Tag Archives: JEE 7

CDI 1.1/1.2 Im-/Ex-plicit bean archives

Implicit bean archive
CDI 1.1 introduced the notation of implicit bean archives, making the inclusion of beans.xml optional. Only beans annotated with bean defining annotations will be considered.

An implicit bean archive is any other archive which contains one or more bean classes with a bean defining annotation, or one or more session beans.
CDI 1.1 specification, 12.1. Bean archives

It is important to note that CDI 1.1 defined all JSR-330 javax.inject.* annotations as bean defining, however this caused some problems with archives that use other JSR-330 compliant injection frameworks, most notably google guava library.

The CDI 1.2 maintenance release addresses these by limiting bean defining annotations to:

  • @ApplicationScoped, @SessionScoped, @ConversationScoped and @RequestScoped annotations,
  • all other normal scope types,
  • @Interceptor and @Decorator annotations,
  •  all stereotype annotations (i.e. annotations annotated with @Stereotype),
  •  and the @Dependent scope annotation.

CDI 1.2 specification, 2.5.1. Bean defining annotations

Any bean that does not define at least one bean defining annotation, will be ignored by CDI. Most notably beans solely defining @Named or CDI pseudo-scopes other than @Dependent, such as @Singleton will be ignored.
Continue reading CDI 1.1/1.2 Im-/Ex-plicit bean archives