Announcement Announcement Module
Collapse
No announcement yet.
JNDI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JNDI

    I am probably missing something very obvious but for the life of me I cannot find any information regarding this. When you specify a JndiObjectFactoryBean, you specify the jndiName but where does it pick up which JNDI provider it is using?

  • #2
    JndiObjectFactoryBean looks up objects using the default JNDI environment used by your container (Tomcat, Jboss, ...).
    It works the same way as if you were looking up a datasource registered in tomcat from a servlet you:
    Code:
      //lookup using default settings
      InitialContext ctx = new InitialContext();
      DataSource ds = (DataSource) ctx.lookup (path);
    It is possible to override the default settings using the property environment of JndiObjectFactoryBean. environment is of type java.util.Properties.

    Comment


    • #3
      Thanks for that - is it possible to pass the environment properties in via the application context or bean factory? I have not been able to locate any examples of this or work out what the paramterisation would be.

      Thanks in Advance.

      Comment


      • #4
        Code:
                <property name="environment">
                    <props>
                        <prop key="foo">bar</prop>
                    </props>
                </property>

        Comment


        • #5
          Absolutely,
          Code:
            <bean name="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiName">
                <value>java&#58;env/comp/jdbc/dataSource</value>
              </property>
              <property name="environment">
                <props>
                  <prop key="key1">value1</prop>
                  <prop key="key2">value2</prop>
                  <prop key="key3">value3</prop>
                </props>
              </property>
            </bean>
          I am sorry if i was not enough clear in my first relpy.

          Comment


          • #6
            Excellent thanks alot, for some reason I have had a complete blind spot over this. Much appreciated.

            Comment

            Working...
            X