JNDI issues -> POJO cannot locate EJBs correctly
ltcmelo Sep 9, 2004 11:02 AMHi,
i'm facing a very very weird problem.
Basically, i got POJOs that can locate EJBs and POJOs that cannot locate EJBs. This seems to be a random behaviour.
Here is.
I use POJO business objects in a layer between my session façades and my cmps.
I already have on use case working like this: the façade doesn't make references to other ejbs (neither in ejb-jar.xml nor jboss.xml), as it delegates the work to a business POJO.
This is business POJO looks for a local interface in the following way.
partyHouseLocalHome = (PartyHouseLocalHome)ejbHomeFactory.lookupByLocalEJBReference("PartyHouseLocal");
The above code is inside the POJO's constructor. Everything works perfectly fine. I afirm: The façade which delegates to this POJO, which is the PartyIssuesBean, does not have any reference in ejb-jar.xml and jboss.xml to the bean PartyHouseBean, the one i'm looking for in the above code.
So, today i was creating a new use case and build a very similar archicture -> a session façade that delegates to a POJO.
I build a brand new session façade that does not reference any other bean in ejb-jar.xml and jboss.xml. This façade delegates to a POJO that, inside it's constructor, look for the following ejbs.
partyHouseLocalHome = (PartyHouseLocalHome)ejbHomeFactory.lookupByLocalEJBReference("PartyHouseLocal"); partyNegotiationLocalHome = (PartyNegotiationLocalHome)ejbHomeFactory.lookupByLocalEJBReference("PartyNegotiationLocal");
Here's the weird thing, on the second lookup i get a javax.ejb.NameNotFoundException !!!!
The lookup for the PartyHouseBean works, but the lookup for the PartyNegotiationBean does not work!!!
Then, i decided to add a reference (in ejb-jar.xml and jboss.xml) to the PartyNegotiationBean for the Session façade the delegates to this POJO.
With that, i lookup works fine !!!!
In other words:
- When i lookup from this POJO for the PartyHouseBean (as in the code above) i do not need a reference to PartyHouseBean in ejb-jar.xml or jboss.xml for the façade that uses this POJO.
- When i lookup from this POJO for the PartyNegotiationBean, it only works if a set a reference to PartyNegotiationBean in ejb-jar.xml and jboss.xml for the façade that uses this POJO.
How weird is that????
I couldn't see any thing diferent between the code of PartyHouseBean and PartyNegotiationBean..., is there some kind of externalize????
ejb-jar.xml
<session > <description>[CDATA[]]</description> <ejb-name>EventPromotion</ejb-name> <home>ltcmelo.homeinterface.EventPromotionHome</home> <remote>ltcmelo.remoteinterface.EventPromotion</remote> <local-home>ltcmelo.localhomeinterface.EventPromotionLocalHome</local-home> <local>ltcmelo.localinterface.EventPromotionLocal</local> <ejb-class>ltcmelo.session.EventPromotionSession</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <!-- THIS IS THE FACADE THAT DELEGATES TO THE POJO. IN THE POJO I C PERFECTLY LOCATE THE PartyHouseBean WITHOUD SETTING A LOCAL REF, BUT I CAN ONLY LOCATE THE PartyBean IF I INSERT THIS REFERENCE --> <ejb-local-ref > <ejb-ref-name>ejb/PartyLocal</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <local-home>ltcmelo.localhomeinterface.PartyLocalHome</local-home> <local>ltcmelo.localinterface.PartyLocal</local> <ejb-link>Party</ejb-link> </ejb-local-ref> </session>
jboss.xml
<session> <ejb-name>EventPromotion</ejb-name> <jndi-name>EventPromotionBean</jndi-name> <local-jndi-name>EventPromotionLocal</local-jndi-name> <!-- I NEED TO ADD THIS REFERENCE SO MY POJO CAN WORK WITH THE PartyBean!!! NOTE THAT THE POJO LOCATES THE PartyHouseBean AND I DON'T HAVE A REF. TO PartyHouseBean HERE. --> <ejb-local-ref> <ejb-ref-name>ejb/PartyLocal</ejb-ref-name> <jndi-name>PartyLocal</jndi-name> </ejb-local-ref> <method-attributes> </method-attributes> </session>
Thanks for any help.