error file facesProduces

Asked

Viewed 54 times

0

is making a mistake

Caused by: org.jboss.Weld.exceptions.Deploymentexception: WELD-001409: Ambiguous dependencies for type Httpservletrequest with Qualifiers @Default at Injection point [Backedannotatedfield] @Inject private com.oliveira.pedidovenda.controller.Loginbean.request at com.oliveira.pedidovenda.controller.Loginbean.request(Loginbean.java:0) Possible dependencies: - WELD%Abstractbuiltinbean%C: Users Adriano Documents Netbeansprojects Pedidovenda target Pedidovenda-1.0-SNAPSHOT WEB-INF classes%Httpservletrequest, - Producer Method [Httpservletrequest] with Qualifiers [@Any @Default] declared as [[Backedannotatedmethod] @Produces @Requestscoped public com.oliveira.pedidovenda.util.jsf.FacesProducer.getHttpServletRequest()]

1 answer

0

just read a little its error log to see the problem: "Ambiguous dependencies for type Httpservletrequest with Qualifiers". No jsf expert, but I know this error occurs when you’re injecting dependency but the CDI can’t find the specific object, or class you want to inject. You can solve this with Java Qualifiers, works as annotation. I’m going to exemplify with my DAO producer. Qualifier

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE,ElementType.PARAMETER,ElementType.FIELD})
public @interface DAOPadrao {

}

Make necessary imports now in the production class:

@ApplicationScoped
public class DAOProducer implements Serializable {

@Produces
@RequestScoped
@DAOPadrao
public SuperDAO superDAO() {
    return new SuperDAO();
}
}

Basically it’s just you create your qualifier annotation and annotate the producer method with it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.