Results 1 to 3 of 3

Thread: using a <jee:jndi-lookup string inside an instance of PropertyPlaceholderConfigurer

  1. #1
    Join Date
    Dec 2011
    Posts
    5

    Default using a <jee:jndi-lookup string inside an instance of PropertyPlaceholderConfigurer

    Environment: Windows server 2003, Spring 3.0, Tomcat 6

    How can I use a JNDI property inside a PropertyPlaceholderConfigurer?

    Specifically, I'm using JNDI to look up a java.lang.String that represents a path to a property file needed by my webapp

    <jee:jndi-lookup id="mypropsfile1" jndi-name="myPropsFile1" resource-ref="true"/>
    <jee:jndi-lookup id="mypropsfile2" jndi-name="myPropsFile2" resource-ref="true"/>

    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
    <property name="locations">
    <array>
    <value>how to use mypropsfile1 here ??</value>
    <value>how to use mypropsfile2 here ??</value>
    </array>
    </property>
    </bean>

    My "jee:jndi-lookup"s are working AFAIK. My problem seems to be how to reference JNDI resources inside the tag pair

    Thanks in advance!
    Mark

  2. #2
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    I've never tried this. but why not just use <ref> tags instead of your <value> tags. <ref bean="mypropsfile1"/>

    Mark

  3. #3
    Join Date
    Dec 2011
    Posts
    5

    Default

    I had stumbled upon the following and it works:

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
    <property name="locations">
    <list>
    <bean class="org.springframework.core.io.FileSystemResou rce">
    <constructor-arg>
    <jee:jndi-lookup id="props1" jndi-name="properties-1" resource-ref="true" />
    </constructor-arg>
    </bean>

    <bean class="org.springframework.core.io.FileSystemResou rce">
    <constructor-arg>
    <jee:jndi-lookup id="props2" jndi-name="properties-2" resource-ref="true" />
    </constructor-arg>
    </bean>
    </list>
    </property>
    </bean>




    Regarding your suggestion, I assume you mean I could do this?

    <jee:jndi-lookup id="props1" jndi-name="properties-1" resource-ref="true" />
    <jee:jndi-lookup id="props2" jndi-name="properties-2" resource-ref="true" />

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
    <property name="locations">
    <list>
    <ref bean="props1"/>
    <ref bean="props2"/>
    </list>
    </property>
    </bean>

Tags for this Thread

Posting Permissions

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