read jndi Environment with @Value annotation, spring 3.1.2.FINAL
I'm re-factoring properties from an application's property file (read using ServletContextPropertyPlaceholderConfigurer ) to an application tomcat context file. I'd like to continue to read these properties in my java code using @Value annotation, e.g.
@Component
@Singleton
@Path("subscription/v1")
public class SubscriptionAdapter {
@Value("${subscription.endpoint}" )
private String endpointurl = null; //
}
When spring tries to inject the @Value("${subscription.endpoint}" ) at runtime I get :
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'subscriptionAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: private java.lang.String com.sas.ost.widget.service.SubscriptionAdapter.end pointurl; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'subscription.endpoint' in string value [${subscription.endpoint}]
at org.springframework.beans.factory.annotation.Autow iredAnnotationBeanPostProcessor.postProcessPropert yValues(AutowiredAnnotationBeanPostProcessor.java: 287)
... etc
===
===
===
Additional context:
Tomcat context file defines props using "Environment".
<Environment name="subscription.endpoint" value="http://blah.com/stuff/" type="java.lang.String" override="false"/>
I have the annotation :
<context:property-placeholder />
I see that JndiPropertySource.getProperty is called for other properties in my spring context file, for example "${SOMETHING}" below:
<bean class="org.springframework.web.context.support.Ser vletContextPropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="searchContextAttributes" value="true"/>
<property name="contextOverride" value="true"/>
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<list>
<value>classpath:common_foo_${SOMETHING}.propertie s</value>
<value>classpath:local.properties</value>
</list>
</property>
</bean>