A Java class is a managed bean if it meets all of the following conditions:
is not an inner class.
It is a non-abstract class, or is annotated @Decorator.
It does not implement jakarta.enterprise.inject.spi.Extension.
It is not annotated @Vetoed or in a package annotated @Vetoed.
It has an appropriate constructor - either:
the class has a constructor with no parameters, or
the class declares a constructor annotated @Inject.
All Java classes that meet these conditions are managed beans and thus no special declaration is required to define a managed bean.
Furthermore, a bean may or may not be an alternative.
Diagnostics
Identify @Inject field/method/constructor
Locate all the dependency classes that are qualified as a managed bean.
If none of the dependency classes matches exactly the bean type, qualifiers and selected alternatives, deliver an diagnostic error at the injection point that no satisfying classes found
If the matching dependency class has no implementations, deliver a diagnostic error that the bean has no implementation (example)
Note 1: Only one dependency class must match, else ambiguous error would be thrown #163Note 2: Diagnostics involving identifying annotation existence might not be possible and depends on #159
[INFO] [ERROR ] CWWKZ0004E: An exception occurred while starting the application demo-servlet. The exception message was: com.ibm.ws.container.service.state.StateChangeException: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Greeting with qualifiers @Named
[INFO] at injection point [BackedAnnotatedField] @Inject @Named private io.openliberty.sample.jakarta.di.unsatisfied.name.GreetingServlet.greeting
[INFO] at io.openliberty.sample.jakarta.di.unsatisfied.name.GreetingServlet.greeting(GreetingServlet.java:0)
[INFO] WELD-001475: The following beans match by type, but none have matching qualifiers:
[INFO] - Managed Bean [class io.openliberty.sample.jakarta.di.unsatisfied.name.Greeting] with qualifiers [@Any @Default]
Unsatisfied and ambiguous dependencies
Which Java classes are managed beans?
Dependency injection and lookup
Beans and Attributes
Diagnostics
@Inject
field/method/constructorNote 1: Only one dependency class must match, else ambiguous error would be thrown #163 Note 2: Diagnostics involving identifying annotation existence might not be possible and depends on #159
Example
The following is a fault code snippet example with
@Qualifier
:Related to #153