I need to read the environment variable defined in my web.xml
<env-entry> <description>Path Repositorio NFS</description> <env-entry-name>PATH_ENV</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>C:/V3</env-entry-value> </env-entry>
from my applicationContext.xml
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="${PATH_ENV}/myprop.properties" /> </bean>
How can i do this?
Finally, I did the following:
1 Define the environment variable in context.xml:
<Environment name="PATH_ENV" type="java.lang.String"/>
2 Define env-entry in web.xml
<env-entry> <description>Path Repositorio NFS</description> <env-entry-name>PATH_ENV</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>/WEB-INF/</env-entry-value> </env-entry>
3 Define in applicationContext.xml
<bean id="configurationPath" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:comp/env/PATH_ENV</value> </property> </bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <bean factory-bean="configurationPath" factory-method="concat"> <constructor-arg value="myprop.properties"/> </bean> </property> </bean>
This works correctly, but if I define the full path in:
<env-entry-value>C:/V3/</env-entry-value>
I have the following problem:
java.io.FileNotFoundException: Could not open ServletContext resource [/C:/V3/aesantasa.properties]
I cannot determine the full path in env-entry-value Why?
Geme
source share