J2EE: ejb-ref and raw JNDI Names ?

J

joes

Hello there

I am new to J2EE. I try to understand how we have to configure the web
tier(servlet or jsp) in order to access an EJB over JNDI. So I am not
quite sure if I did understand the ejb-ref principle. May be someone
could delight me and explain me what the advantages there are.

I saw that some examples are using a "<ejb-ref>" in the "web.xml" and
in the specific "app.container-ejb-jar.xml". As far as I understand
the EJB container is assigning a raw JNDI Name for registering the
HomeObject. In order to avoid a hardcoding of a raw JNDI Name in the
lookup part of my client code I should use a reference of this JNDI
Name which is defined in the "app.container-ejb-jar.xml" and also in
the "web.xml". And exactly at this point I do not understand the real
advantage of <ejb-ref>. So some questions:

- what is a raw JNDI name ? How could they physically look like ? What
is the difference regarding the common JNDI Names as like
"java:comp/env/MyName" ?

- Does this mean it exists always two JNDI entries for a EJB
HomeObject (a raw and a reference) ?

- Why I have to define the reference mapping in both files, means once
in the app.containe-ejb-jar.xml and once in the web.xml ? Because
ejb-ref can only be used within the same container, so an application
has also the same JNDI context. Why I do have to list it explicitely
again in the web.xml ? i.e. sunone application container, j2ee
tutorial converter.

thank you in advance for any helpful comments regarding this.
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top