CDI discovery-mode annotated doesn't scan stereotypes bean

cdi, java, jsf, stereotype

Solution

With the `bean-discovery-mode="annotated"` in CDI 1.1, only beans annotated with a bean defining annotation are picked up by CDI as beans. This is described in the CDI 1.1 specification, chapter 2.5. As can be seen there, stereotypes are not included in the set of bean-defining annotations. Only scope types are bean-defining.

The `@Model` annotation is a built-in CDI stereotype. Therefore in CDI 1.1, annotating a bean `@Model` is not enough to get it discovered in the `annotated` discovery mode.

This is, however, going to change with CDI 1.2 (chapter 2.5.1), where stereotypes are considered bean-defining annotations.

Problem

Why `bean-discovery-mode="annotated"` doesn't scan beans annotated with some stereotype, such as `@Model` - I just tried that and classes annotated this way weren't pick up by CDI so I had to change the mode back to the `all`. So is this a bug (because for instance `@Model` has a scope) or is this by design?

Original source