• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Refs ( coded name and JNDI name )

 
Tarun Tyagi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic