CR1: @Qualifier linked with @Alternative
alexanderbell Oct 16, 2009 12:47 PMHi,
I've got two Producer-Methods which provide an EntitiyManager:
@Produces @Persistence public EntityManager getEntityManager() {...}
@Produces @Test @Persistence public EntityManager getTestEntityManager() {...}
My meta-annotations:
@Qualifier @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER}) public @interface Persistence {}
@Alternative @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE}) public @interface Test {}
And my beans.xml
<beans> <alternatives> <!--stereotype>eu.unicreditgroup.cope.type.Test</stereotype--> <!--stereotype>eu.unicreditgroup.cope.type.Mock</stereotype--> </alternatives> </beans>
So the two alternatives are disabled.
Last but not least my injection point:
public class TestServiceImpl implements TestService { private @Inject @Persistence EntityManager em; }
So, actually the injection point is unambiguous but I get the following Exception:
org.jboss.weld.DeploymentException: Injection point has ambiguous dependencies. Injection point: field eu.unicreditgroup.cope.service.impl.TransactionlistServiceImpl.em; Qualifiers: [@eu.unicreditgroup.cope.type.Persistence()]; Possible dependencies: [org.jboss.weld.bean-web-module-ProducerMethod-eu.unicreditgroup.cope.util.PersistenceUtil.getEntityManager(), org.jboss.weld.bean-web-module-ProducerMethod-eu.unicreditgroup.cope.util.PersistenceUtil.getTestEntityManager()] at org.jboss.weld.Validator.validateInjectionPoint(Validator.java:166) at org.jboss.weld.Validator.validateBean(Validator.java:75) at org.jboss.weld.Validator.validateRIBean(Validator.java:95) at org.jboss.weld.Validator.validateBeans(Validator.java:211) at org.jboss.weld.Validator.validateDeployment(Validator.java:198) at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:295) at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:156) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
With the previous version (WebBeans) it works with the deprecated Annotations @BindingType and @DeploymentType
Any ideas?
Alex