-
1. Re: Veto a Session bean
mkouba Feb 28, 2014 3:12 AM (in response to acheaito)Hi Ali,
that's odd. In CDI 1.0 the session bean that is not in a bean archive should never be discovered. Actually it seems it is not - as ProcessAnnotatedType is not fired. What does the injection point look like? How did you find out that EjbWorker is registered?
-
2. Re: Re: Veto a Session bean
acheaito Feb 28, 2014 10:31 AM (in response to mkouba)I left out some details that seemed irrelevant. We have a Portable Extension (ServiceBeanCreator) that registers beans from non-discoverable archives by means of AfterBeanDiscovery event.addBean(). One such bean is RegularWorker, which also implements WorkerInterface. The extension runs fine and the beans register, however when the bean is requested from BeanManager like so:
Bean<WorkeInterface> bean = (Bean<WorkeInterface>) beanManager.resolve(beanManager.getBeans(WorkerInterface.class, new AnnotationLiteral<Default>(){})); WorkerInterface instance = beanManager.getContext(bean.getScope()).get(bean, beanManager.createCreationalContext(bean));
an exception is thrown:
org.jboss.weld.exceptions.AmbiguousResolutionException: WELD-001318 Cannot resolve an ambiguous dependency between [com.company.cdi.ext.ServiceBeanCreator$1@37b6b182, Session bean [class com.company.worker.impl.ejb.EjbWorker with qualifiers [@Any @Default]; local interfaces are [EjbWorker]]
Also, in the extension, I listen to ProcessSessionBean and ProcessManagedBean and both are called for EjbWorker.
-
3. Re: Re: Veto a Session bean
mkouba Mar 3, 2014 4:03 AM (in response to acheaito)The container should definitely not fire ProcessManagedBean for any session bean. Could you provide a simplified version of your archive, so that we're able to reproduce your issue locally?
-
4. Re: Re: Re: Veto a Session bean
acheaito Mar 3, 2014 9:36 AM (in response to mkouba)Simplified version attached as requested.
The TestJar Eclipse project has the interface, impl, and Ejb.
TestWeb has the injection target as well as the portable extension. Once Deployed, clicking the doWork button on the index.xhtml will throw the ambiguous resolution exception.
-
cdiEjbProblem.zip 1.2 MB
-
-
5. Re: Re: Re: Veto a Session bean
mkouba Mar 3, 2014 11:08 AM (in response to acheaito)Would it be possible to attach the final WAR? I don't use the required Eclipse plugins.
-
6. Re: Re: Re: Re: Veto a Session bean
acheaito Mar 4, 2014 8:33 AM (in response to mkouba)Attached. This was compiled with Java 7.
EDIT: Just realized I left out the source files from the WAR export. Here's a version with the source.
-
TestWeb.war 1.2 MB
-