-
1. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
wujek Oct 6, 2010 2:08 PM (in response to andersaa)According to the specs, a CDI bean doesn't have to be annotated @ManagedBean or anything - every class that belongs to a jar that has META-INF/beans.xml, and:
(specs 3.1.1)
A top-level Java class is a managed bean if it is defined to be a managed bean by any other Java EE specification, or if it
meets all of the following conditions:
• It is not a non-static inner class.
• It is a concrete class, or is annotated @Decorator.
• It is not annotated with an EJB component-defining annotation or declared as an EJB bean class in ejb-jar.xml.
• It does not implement javax.enterprise.inject.spi.Extension.
• It has an appropriate constructor—either:
• the class has a constructor with no parameters, or
• the class declares a constructor annotated @Inject.
All Java classes that meet these conditions are managed beans and thus no special declaration is required to define a man-
aged bean.So, your class has a no-arg constructor and is in a bean archive, so it is a bean. So now you have 2 beans with the same types. You could just annotate the UserData class with @SessinoScoped and drop the producer, or do something that will prevent the class to be discovered as a bean. You can add a constructor with parameters (yuck!), you can create @Veto or similar annotation, annotate the class and create a portable extension that vetoes all classes that have this @Veto annotation (I believe there is weld-extensions somewhere that does this), or maybe try @Specializes or @Alternative. Adding a dummy qualifier would also work.
I personally hate the default behaviour of everything being a bean, and having it so difficult / dirty to turn it off. Hopefully a maintenance release will fix this? -
2. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
cpopetz Oct 6, 2010 4:30 PM (in response to andersaa)I love the default behavior. It is not hard to add an @Alternative to a class you want to @Produce elsewhere.
One improvement I could see is that if a class has a @Produce that produces its own unqualified type, the class itself should not get marked as a bean. That would solve a common use case, IMHO.
-
3. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
meetoblivion Oct 6, 2010 8:44 PM (in response to andersaa)While not particularly great, in most cases you will want to use qualifiers.
-
4. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
nickarls Oct 7, 2010 2:06 AM (in response to andersaa)I usually stick @Typed({}) on the POJO so it isn't considered...
-
5. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
wujek Oct 7, 2010 3:01 AM (in response to andersaa)All these solutions require to add some CDI annotations to your classes, which some people might not want. But I agree, sometimes it is nice to have it automatic. But for the most part, this has been a nightmare for us. Just my 2cc.
-
6. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
alin.heyoulin.qq.com Oct 7, 2010 3:51 AM (in response to andersaa)I think weld should configure beans.xml like this <weld:scan> <!-- Just scan that classes annotated @xx.xx.xx in packege com.xx.xx--> <weld:include name="com.xx.xx.**"> <weld:if-class-isAnnotationPresent name="xx.xx.xx"/> </weld:exclude> </weld:scan> or <weld:scan> <!-- Just scan that classes not annotated @xx.xx.xx in packege com.xx.xx--> <weld:include name="com.xx.xx.**"> <weld:if-class-isAnnotationPresent name="!xx.xx.xx"/> </weld:exclude> </weld:scan>
-
7. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
alin.heyoulin.qq.com Oct 7, 2010 3:52 AM (in response to andersaa)I think weld should configure beans.xml like this <weld:scan> <!-- Just scan that classes annotated @xx.xx.xx in packege com.xx.xx--> <weld:include name="com.xx.xx.**"> <weld:if-class-isAnnotationPresent name="xx.xx.xx"/> </weld:include> </weld:scan> or <weld:scan> <!-- Just scan that classes not annotated @xx.xx.xx in packege com.xx.xx--> <weld:include name="com.xx.xx.**"> <weld:if-class-isAnnotationPresent name="!xx.xx.xx"/> </weld:include> </weld:scan>
-
8. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
wujek Oct 8, 2010 3:36 AM (in response to andersaa)Show these XMLs to Gavin. And start running the other way very quickly :D
-
9. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
meetoblivion Oct 10, 2010 9:49 AM (in response to andersaa)Well actually SEAM3 has an XML module. http://sfwk.org/Seam3/XMLConfigurationModule
-
10. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
alin.heyoulin.qq.com Oct 10, 2010 11:10 AM (in response to andersaa)I prefer to scan only the classes needed to avoid excessive memory and cpu consumption caused by mass bean definitions at weld initialization phase。And those not be loaded classes can be loaded with initialization parameters by xml module.Just like seam2's components.xml and @Install(precedence = BUILT_IN, dependencies="xxx").
-
11. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
alin.heyoulin.qq.com Oct 10, 2010 11:11 AM (in response to andersaa)I prefer to scan only the classes needed to avoid excessive memory and cpu consumption caused by mass bean definitions at weld initialization phase。And those not be loaded classes can be loaded with initialization parameters by xml module.Just like seam2's components.xml and @Install,precedence,dependencies.
-
12. Re: Getting "Injection point has ambiguous dependencies", but there is only one producer
wujek Oct 10, 2010 11:50 AM (in response to andersaa)That it does doesn't mean anything. Gavin didn't write it, someone else who is (possibly) fond of XML config did. If you search the web you will find many heated discussions with Gavin and should notice how affectionate he is about it. Heck, the XML config from Web Beans has been dropped as well - a real config that would let you configure beans, producers and so on (pretty much what the Seam module does), not the stub that beans.xml is now.