Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 980183

Summary: EJB in CDI enabled module gets registered twice leading to WELD-001409 Ambiguous dependencies...
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Brad Maxwell <bmaxwell>
Component: CDI/WeldAssignee: Stuart Douglas <sdouglas>
Status: CLOSED CURRENTRELEASE QA Contact: Marek Schmidt <maschmid>
Severity: medium Docs Contact: Russell Dickenson <rdickens>
Priority: unspecified    
Version: 6.1.0CC: cdewolf, istudens, maschmid, myarboro, nicolas.ternisien, pmuir
Target Milestone: ER2   
Target Release: EAP 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-15 16:21:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Brad Maxwell 2013-07-01 15:37:33 UTC
Description of problem:

If you have this no-interface @Stateless EJB in the module and have a
beans.xml inside the module jar as well and then have a deployment
depends on & imports the annotations, and then uses @Inject TestEjb,
Weld will complain that there are two options an EJB and a ManagedBean
and it doesn't know which to inject. According to [1] it should only be
considered a managed bean if "It is not annotated with an EJB
component-defining annotation or declared as an EJB bean class in
ejb-jar.xml 	."

The error:

WELD-001409 Ambiguous dependencies for type [TestEjb] with qualifiers [@Default] at injection point [[field] @Inject test.webapp.TestService.testEjb].
Possible dependencies [[Session bean [class test.TestEjb with qualifiers [@Any @Default]; local interfaces are [TestEjb], Managed Bean [class test.TestEjb] with qualifiers [@Any @Default]]]

@Stateless
public class TestEjb
{
public String hello()
{ return "Hello"; }

}

If I move all of the classes into the test war, then Weld doesn't have
an issue, so it seems there is some difference when the code is put into
the modules directory.

[1] http://docs.jboss.org/weld/reference/1.0.1-Final/en-US/html_single/#d0e792


How reproducible:

Steps to Reproduce:
1. put a no-interface view EJB into a jar, include a beans.xml in the jar to make it CDI enabled.  
2. Run jandex to generate a jandex index for the annotations.
3. Put the jar into a custom module in $JBOSS_HOME/modules/
4. Deploy a test.war that tries to inject using @Inject and depends on the custom module via module dependencies with meta-inf=import and annotations=true

Actual results:

Deployment fails as there are two options for injection: EJB & CDI bean.  Workaround change @Inject to @EJB

WELD-001409 Ambiguous dependencies for type [TestEjb] with qualifiers [@Default] at injection point [[field] @Inject test.webapp.TestService.testEjb].
Possible dependencies [[Session bean [class test.TestEjb with qualifiers [@Any @Default]; local interfaces are [TestEjb], Managed Bean [class test.TestEjb] with qualifiers [@Any @Default]]]


Expected results:

EJB is registered as an EJB only , not a CDI module.  @Inject on the no-interface view of the EJB results in the EJB being injected

Additional info:

Comment 4 Ivo Studensky 2013-09-03 13:02:13 UTC
relevant 6.2 PR: https://github.com/jbossas/jboss-eap/pull/345