Forums Register Login

EJB Refs ( coded name and JNDI name )

+Pie Number of slices to send: Send
Hi

I am just starting to develop EJBs . I can't get to work the EJB refs as expected . In a session bean I have a lookup for an Entity bean . Both beans are in separate JAR files , but in the same ear .

The lookup from session bean to entity bean only works when
the coded name in EJB ref is defined exactly the same as JNDI name for enity bean , also the name in lookup method must be the same in session bean .

To my surprise , the JNDI name for the target EJB , defined in EJB ref for session bean , does not mater at all . Even if I change it to a non existant name , the bean lookup works .

Theoritacally I understand that EJB ref is there to provide a mapping between the name of bean mentioned in code to the actual JNDI name of another bean , at the time of deployment .

The above is happening in J2EE 1.4 envoirment .

Please let me know , what am I doing here that is wrong .

( All examples and tutorials , usually give coded name same as JNDI name ) .

Thanks
Tarun
+Pie Number of slices to send: Send
Without seeing what your deployment descriptors look like, or knowing what server you're using here's the following information:

ejb-refs definitely do what they're supposed to. In fact, you need (actually, are supposed to) fully specify what is being linked to using the ejb-link element (names may be incorrect, sorry). That being said, some containers may actually fix that to make it work if they can. For example, if you only specify the interfaces, and there is only one bean that uses that one, it knows what to do with the ejb-ref, etc.

I would definitely use ejb-refs all the time. That is what the EJB spec tells us to do. As for linking ejb-refs to a bean in another jar within the same ear, you should consult the specs for more information. You would use something like <ejb-link>module.jar/#BeanName</ejb-link>. That may be wrong, but it's pretty close.

Read the spec.
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 792 times.
Similar Threads
Problem referencing EJB in web application on Websphere
ejb-ref lookup does not work with JBoss 4.2.0GA _CP07, pleas help.
Jboss and Ejb 2.1 ejb-ref lookup
JNDI Lookup/ejb-jar.xml to find an another ejb
problems with JNDI name lookup
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:19:42.