-
Dec 23rd, 2011, 03:49 PM
#1
<j2ee:jndi-lookup default-value attribute problem
I am using j2ee:jndi lookup for a property file. The following works great:
<bean class="org.springframework.core.io.FileSystemResou rce">
<constructor-arg>
<jee:jndi-lookup id="myProps" jndi-name="myProps" resource-ref="true" />
</constructor-arg>
</bean>
However, I want to handle the case where the jndi lookup fails but can fall back on a default file located in WEB-INF/classes folder. If I use the default-value as below, the webapp throws an exception complaining that it cannot find the file "classpath:myprops.properties"
<bean class="org.springframework.core.io.FileSystemResou rce">
<constructor-arg>
<jee:jndi-lookup id="myProps" jndi-name="myProps" resource-ref="true"
default-value="classpath:myprops.properties" />
</constructor-arg>
</bean>
Is there anyway around this? I need to have a relative path to the myprops.properties that looks inside my webapp's installation. (note; when I hard code a fixed path above, it works fine, but that is unacceptable as a final solution).
This is the overall usage I'm employing:
<bean id="authServerProperties" class="org.springframework.beans.factory.config.Pr opertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
<property name="location">
<bean class="org.springframework.core.io.FileSystemResou rce">
<constructor-arg>
<jee:jndi-lookup id="myProps" jndi-name="myProps" resource-ref="true"
default-value="classpath:myprops.properties" />
</constructor-arg>
</bean>
</property>
.....
</bean>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules