Ronaldo Lanhellas
Ronaldo Lanhellas

Reputation: 3356

CDI @Named annotation dont work as expected

I annoted the class ParametroSistemaHelper in this way:

@Named
@ApplicationScoped
public class ParametroSistemaHelper {

    @Inject
    private BasicDAO dao;

After this i'm trying to use this in another class:

public abstract class BasicCrudMBImpl {    

    @Inject
    private ParametroSistemaHelper parametroSistemaHelper;

But when i try to start server (tomcat) i got error:

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ParametroSistemaHelper with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private br.com.jwebbuild.mb.BasicCrudMBImpl.parametroSistemaHelper
  at br.com.jwebbuild.mb.BasicCrudMBImpl.parametroSistemaHelper(BasicCrudMBImpl.java:0)

I noted that in start of server the following message apper:

Managed Bean [class br.com.cardoso.mb.DisciplinaMBImpl] with qualifiers [@Default @Named @Any]

Upvotes: 0

Views: 514

Answers (1)

A.Panzer
A.Panzer

Reputation: 391

Probably ParametroSystemaHelper is annotated by @javax.faces.bean.ApplicationScoped instead of @javax.enterprise.inject.ApplicationScoped. CDI container scans application for CDI beans but can't find your bean because scope is not defined explicitly. This is for CDI 1.1 when beans.xml contains bean-discovery-mode="annotated" or is omitted that also means annotated discovery mode.

Upvotes: 1

Related Questions