-
1. Re: Cross reference between .ear
wdfink Jan 15, 2014 2:26 AM (in response to marvinsouza)You might use jboss-all.xml, see here for more information.
In that case set the lookup or beanname attribut for @EJB should do the work
-
2. Re: Re: Cross reference between .ear
marvinsouza Jan 17, 2014 7:16 AM (in response to wdfink)To the problem of the order of deployments, I resolved with this descriptor (jboss-all.xml).
But what I want, using the refered example (http://www.mastertheboss.com/jboss-deploy/solving-ear-deployment-dependencies-in-jboss-as-7) it is:
I have EJBs in app1.ear that have fields annotated with @EJB of the type of the EJBs from app2.ear. To the injection to work properly, I have to declare, in app1.ear, in file ejb-jar.xml all my EJBs configuring the dependencies explicitly. Example:
@Stateless public class App1Foo implements IApp1Foo { @EJB(name="bar") private App2Bar bar; }
This injection only works if I create the ejb-jar.xml, in app1.ear, app1-ejb.jar with this:
<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" version = "3.1" 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"> <enterprise-beans> <session> <ejb-name>App1Foo</ejb-name> <ejb-ref> <ejb-ref-name>bar</ejb-ref-name> <lookup-name>java:global/app2/app2-ejb/BarBean</lookup-name> </ejb-ref> </session> <enterprise-beans> </ejb-jar>
I am searching for an alternative to do this manually. My first option would be the container have some configuration to make it lookup in global JNDI tree first, without ejb-jar.xml obviously. The second option would be the some tool (maven plugin, etc) that generates the file (ejb-jar.xml) automatically, inspecting all my ejb with @EJB annotation.
-
3. Re: Cross reference between .ear
wdfink Jan 17, 2014 7:20 AM (in response to marvinsouza)What if you add lookup="java:global/app2/app2-ejb/BarBean" to your @EJB annotation?
-
4. Re: Cross reference between .ear
marvinsouza Jan 17, 2014 12:46 PM (in response to wdfink)I could add this, but I would have to modify all my code to this. Besides, the code would be 'ugly'.
In Glassfish v3 ou v4, I don't need to do this. In some way, he discovers the dependency and do the injection. This is a good alternative (to me) because the code remains clean.
If this is not possible in Wildfly, I would like to generate the ejb-jar.xml reading some configuration file, with some default configuration, and instrospecting my beans looking for @EJBs.