blogger templates blogger widgets
This is part of a list of blog posts.
To browse the contents go to

Why we need JNDI in containers or application servers?

Here are few benefits I could think of:

  • We can configure and share objects and resources across multiple applications (but only within the same EAR, using the java:global) using the same JNDI name.
    - only within specific servlet; limited to strings
    - only within that web application; limited to strings

    In general, lookups of objects in the JNDI java: namespace are required to
    return a new instance of the requested object every time. Exceptions are allowed
    for the following(this is from J2EE spec):
    1. The container knows the object is immutable (for example, objects of type
      java.lang.String), or knows that the application can’t change the state of the
    2. The object is defined to be a singleton, such that only one instance of the object may exist in the JVM.
    3. The name used for the lookup is defined to return an instance of the object that
      might be shared. The name java:comp/ORB is such a name.
  • JNDI's object-storage capabilities allow it to play the role of resource administrator in your distributed applications and to provide simple, manageable object persistence. In recognition of its potential, the architects of key Java technologies such as JDBC and EJB built JNDI into their specifications.
  • JNDI is very helpful when you move an application between environments: development to integration to test to production. If you configure each app server to use the same JNDI name, you can have different databases in each environment and not have to change your code.

Continue reading: Configuring JNDI in Tomcat

No comments:

Post a Comment