Leia uma variável de ambiente de applicationContext.xml
Eu preciso ler uma variável de ambiente definida no meu 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>
do meuapplicationContext.xml
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="${PATH_ENV}/myprop.properties" />
</bean>
Como posso fazer isso ?
Finalmente eu fiz o seguinte:
1 Defina a variável de ambiente em context.xml:
<Environment name="PATH_ENV" type="java.lang.String"/>
2 Defina env-entry no 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 Defina em 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>
Isso é executado corretamente, no entanto, se eu definir um caminho completo em:
<env-entry-value>C:/V3/</env-entry-value>
Eu tenho o próximo problema:
java.io.FileNotFoundException: Could not open ServletContext resource [/C:/V3/aesantasa.properties]
Eu não posso definir um caminho completo em env-entry-value Por quê?