Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Distributed Java and the fly likes JNDI Lookups Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "JNDI Lookups" Watch "JNDI Lookups" New topic

JNDI Lookups

Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
I'm wondering about the cost of doing JNDI lookups.. Here's the setup:

1. A business tier has a dozen or so stateless beans that make requests to the back end system and return a result to the caller.

2. a remote web client does a JNDI lookup to one or more of the beans, and may invoke one or more methods on the same remote bean during the POST or GET request.

- do i need to close the JNDI connection when I'm done (i.e. before exiting the POST or GET method of the servlet)?

- is it feasible to have a singleton that holds the jndi connection open? or do I really need to do a new lookup each time I need a stateless bean?

I guess my main concern is the cost of doing the lookup. In all code examples I've seen, when accessing a remote ejb, the lookup is performed each time a bean is required, but I never see code to close the connection.



Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 578
Setup context and remote references from servlet init() and close the context from servlet destroy().
I agree. Here's the link:
subject: JNDI Lookups