I'd like to confirm that the following general approach is the right one
(before I start digging into GlassFish errors :-)):
I have a SLSB (of class foo.XBean with no explicitly assigned bean name, so
its bean name is defaulted to "XBean"). XBean implements a @Local
interface, X (in case it matters).
It has this in it:
@EJB
private Y y;
Standard stuff.
Y in this case is a @Local interface of another SLSB, foo.YBean, of type
@Local Y, packaged in the same .ear file.
Deployment obviously works fine.
Now suppose I add another Y implementor to the ear file: foo.UnwantedYBean.
This is also, let's say, a @Local implementation of Y.
So two @Local Y implementations in the same .ear file and in the case of
XBean no way to distinguish them. Oops.
Obviously and appropriately deployment fails.
So now I want to make it so that my EJB named XBean injects a foo.YBean
proxy into its y field so that deployment will be happy again. Let's say I
can't do this in the annotations.
Is the following deployment descriptor XML (located obviously in XBean's
ejb jar file, in the META-INF directory--no tricks) supposed to do this?
I've tried to simply duplicate the example on page 448 of the EJB 3.1
specification, but using <ejb-local-ref> instead of <ejb-ref>.
<?xml version="1.0" ?> <ejb-jar xmlns="
http://java.sun.com/xml/ns/javaee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1">
<enterprise-beans>
<session>
<!-- The bean name of the EJB whose innards I'm affecting -->
<ejb-name>XBean</ejb-name>
<ejb-local-ref>
<!-- The name of the EJB reference I need to "fill"; originally
declared via annotations -->
<ejb-ref-name>XBean/y</ejb-ref-name>
<!-- The bean name of the EJB in the same Java EE module I'd like
injected into that reference -->
<ejb-link>YBean</ejb-link>
</ejb-local-ref>
</session>
</enterprise-beans>
</ejb-jar>
For some reason, I've always had trouble parsing the EJB specification on
this point.
Thanks,
Laird
--
http://about.me/lairdnelson