jQuery in Action, 3rd edition
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
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

Joined: Apr 04, 2009
Posts: 694

Setup context and remote references from servlet init() and close the context from servlet destroy().
I agree. Here's the link: http://aspose.com/file-tools
subject: JNDI Lookups
It's not a secret anymore!