Description of problem:
I got a case [1] that seems to be a bug. The scenario is: a class have some fields that have different implementations of the declared interface and the client use the beanName/name attribute to tell which one he want. This works fine, but the customer change a beanName/name of an annotated field (by mistake) to something wrong and he didn't got any message from the container saying about the unresolved EJB reference, instead he noticed that the container randomly inject a bean in that field (and we the method was invoked he got some issues due didn't happened hat he expected). So, my question is, is is right expecting the container sending a message to this case? I saw the JSR 220 [2] and I think it is. Some parts of the specification:
16.5.3 Deployer’s Responsibility
If an EJB annotation includes the beanName element or the reference declaration includes the
ejb-link element, the Deployer should bind the enterprise bean reference to the enterprise
bean specified as the target.
16.5.4 Container Provider’s Responsibility
The Container Provider must provide the deployment tools that allow the Deployer to perform the tasks
described in the previous subsection. The deployment tools provided by the EJB Container Provider
must be able to process the information supplied in the ejb-ref and ejb-local-ref elements in
the deployment descriptor.
At the minimum, the tools must be able to:
• Preserve the application assembly information in annotations or in the ejb-link elements
by binding an EJB reference to the business interface or the home interface of the specified target bean.
• Inform the Deployer of any unresolved EJB references, and allow him or her to resolve an EJB
reference by binding it to a specified compatible target bean.
[1] 00804385 - https://c.na7.visual.force.com/apex/Case_View?id=500A000000DMyuD&sfdc.override=1
[2] JSR 220 - http://download.oracle.com/otndocs/jcp/ejb-3_0-fr-eval-oth-JSpec/
Actual results:
Container give any implementation of the interface.
Expected results:
Raise an exception during the deploy/lookup for wrong beanName/name using @EJB
Additional info:
attaching a reproducer made by Brad