• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

DI, JNDI question

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Imagine that you have a business interface by name 'Template'. Which of the following ways can be used by the Client Application to acquire a reference to the business interface (assuming that this interface is bound in the JNDI Context)?


Correct Answer: 4. I agree with 1 and 2.

In answer option 3, should'nt the context look up be something like

template = (Template)Context.lookup("java:comp/env/ejb/template");

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree. But don't worry, it's unlikely that such mistakes occur in the exam (unless the oracle guys turn it upside down ).
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hm. If you change option 3. to use

template = (Template)Context.lookup("java:comp/env/ejb/template");

then options 1. and 2. are no longer correct unless you change them as well.

Option 1.

Option 2.
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it depends on what kind of client you are using.

J2EE component clients or stand-alone client.

If you are using J2EE component clients(Servlet,EJBs,APPlication-client) then all of the above is true but if you are using stand-alone client,none of them is true.

You have to use traditional JNDI look up...

Correct me if i am wrong....
 
Tomas Klubal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The last option 3. is correct even for stand alone client. You can use no arg constructor for initial context if you supply jndi.properties and there is no need to narrow if what you retieve is a business interface.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. You are correct.

Sorry i saw this line "java:comp/ejb/template" as "java:comp/env/ejb/template"

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic