Results 1 to 6 of 6

Thread: JNDI

  1. #1
    Join Date
    Aug 2004
    Posts
    3

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Posts
    3

    Default

    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.

  4. #4
    Join Date
    Aug 2004
    Posts
    27

    Default

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

  5. #5
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  6. #6
    Join Date
    Aug 2004
    Posts
    3

    Default

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

Similar Threads

  1. Replies: 13
    Last Post: Feb 5th, 2010, 12:31 AM
  2. JNDI and Unit testing
    By mperham in forum Container
    Replies: 7
    Last Post: Dec 18th, 2008, 06:56 AM
  3. Replies: 6
    Last Post: Sep 29th, 2005, 04:25 AM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. Ignoring missing Jndi DataSource within IDE?
    By Bill Pearce in forum Container
    Replies: 2
    Last Post: Oct 27th, 2004, 09:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •