WELD-001409: Ambiguous dependencies for type FacesContext with qualifiers @Default when migrating to EAP 8

Solution Verified - Updated -

Issue

We are migrating our JSF application to EAP 8, we use CDI @Inject FacesContext and had a Producer method to produce the FacesContext and it is failing to deploy with this error:

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type FacesContext with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject test.JSFBean.ctx
  at test.JSFBean.ctx(JSFBean.java:0)
  Possible dependencies: 
  - com.sun.faces.cdi.FacesContextProducer@30fd497d,
  - Producer Method [FacesContext] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces @RequestScoped public test.Resources.produceFacesContext()]

    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:375)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:285)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:141)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:515)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:64)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:62)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
    at org.jboss.weld.core@5.0.1.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
    at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)

Our beans look like:

import jakarta.inject.Named;
import jakarta.inject.Inject;
import jakarta.faces.context.FacesContext;
import jakarta.enterprise.inject.Model;

@Model
public class JSFBean {
  @Inject
  FacesContext ctx;
}
import jakarta.faces.context.FacesContext;
import jakarta.enterprise.inject.Produces;
import jakarta.enterprise.context.RequestScoped;

public class Resources {
    @Produces
    @RequestScoped
    public FacesContext produceFacesContext() {
        return FacesContext.getCurrentInstance();
    }
} 

Environment

  • Red Hat Enterprise Application Platform (EAP) 8
  • JSF (Jakarta Faces)
  • CDI (Contexts & Dependency Injection)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content