Bug 980183 - EJB in CDI enabled module gets registered twice leading to WELD-001409 Ambiguous dependencies...
Summary: EJB in CDI enabled module gets registered twice leading to WELD-001409 Ambigu...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: CDI/Weld
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ER2
: EAP 6.2.0
Assignee: Stuart Douglas
QA Contact: Marek Schmidt
Russell Dickenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-01 15:37 UTC by Brad Maxwell
Modified: 2018-12-02 16:38 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-12-15 16:21:04 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker WFLY-1620 0 Major Closed EJB in CDI enabled module gets registered twice leading to WELD-001409 Ambiguous dependencies... 2018-07-25 06:06:11 UTC

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


Note You need to log in before you can comment on or make changes to this bug.