3 Replies Latest reply on Jul 16, 2010 2:13 AM by asiandub

    Injecting @EJB references fails?


      Following the reference documentation example on how to do this sort of thing, I have attempted (obviously badly) to define a bean in one place with @Produces, and to inject that bean into a @SessionScoped object somewhere else (using @Inject).  This combination is ambiguous, somehow, in Glassfish 3.1b09.

      Here is what I've done.  I'm hoping that someone on this list can easily spot my boneheaded, idiotic, thick-skulled pilot error.

      I have attempted to isolate the bean definition into its own class.  Perhaps this is misguided?  Anyhow, here is the class:

      public class FrobnicatorProducer {
        private Frobnicator frobnicator; // frobnicator is a stateless session bean reference

      Then, in my session scoped object, Foobar, I've done this:

      private Frobnicator frobnicator;

      This combination results in the following error:

      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Injection point has ambiguous dependencies.  Injection point:  field com.foobar.Foobar.frobnicator;  Qualifiers:  [@javax.enterprise.inject.Default()]; Possible dependencies: [org.jboss.weld.bean-/usr/local/glassfish-3.1b09/glassfish/domains/domain1/applications/foobar-1.0-SNAPSHOT/foobar-fizbaw-ejb-1.0-SNAPSHOT_jar/-SessionBean-FrobnicatorBean, org.jboss.weld.bean-/usr/local/glassfish-3.1b09/glassfish/domains/domain1/applications/foobar-1.0-SNAPSHOT/foobar-war-1.0-SNAPSHOT_war/-ProducerField-com.foobar.FrobnicatorProducer.frobnicator]

      It appears to me that the session bean (FrobnicatorBean) is already a candidate for injection somehow, and so the producer field version of it is thereby redundant.  If this is true, I don't see how the reference documentation example could possibly work.  Clearly it must; I know the error is mine.  But I don't know where to go from here.