the example seems to be a bit confused. Where's the definition of the @Jdbc annotation (see MyProducer.create)? Also what's the way you are "asking the container", do you use BeanManager or is there another bean with an injection point? A full stack trace would be also helpful.
I'm sorry, replacing names was not completely done. @Jdbc should've been @Def.
I retrieve the instance with:
WeldContainer container = new org.jboss.weld.environment.se.Weld.Weld().initialize();
This code is used for an integration test.
Ok. First of all, TypeLiteral only makes sense for parameterized types. So
instance.select(Type.class)would be better.
WeldContainer.instance().select(new TypeLiteral<Pro>)is actually looking for a bean with type
org.jboss.weld.environment.se.beans.InstanceManager). In your example
OtherProis the only matching bean - the producer method MyProducer.create is ignored because it's not "a default-access, public, protected or private, non-abstract method of a managed bean class or session bean class" (note that MyProducer is not a bean because it doesn't have an appropriate constructor, see also http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#producer_method). If you move the producer method into a separate class (probably a valid bean), there are two beans which satisfy the required type and qualifiers, neither of which is an alternative. And so the container complains about ambiguity.