necesito leer una variable de entorno definida en mi web.xmlLeer una variable de entorno de applicationContext.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>
de mi applicationContext.xml
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="${PATH_ENV}/myprop.properties" />
</bean>
¿Cómo puedo hacer esto?
fin he hecho lo siguiente:
1 Definir variable de entorno en context.xml:
<Environment name="PATH_ENV" type="java.lang.String"/>
2 Definir env-entry en 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 Definir en 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>
Esto se ejecuta correctamente, sin embargo si definir una ruta completa en:
<env-entry-value>C:/V3/</env-entry-value>
tengo el siguiente problema:
java.io.FileNotFoundException: Could not open ServletContext resource [/C:/V3/aesantasa.properties]
I Cant definir una ruta completa en env-interés social valor ¿Por qué?
En caso de que alguien responda a esta pregunta, debería haber sido el archivo ': C:/V3/ env-entry-value>' –
Jamie