Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Injection can not find variable in resource file
    text
    copied!<p>I have a resource file created in my project. I want to inject values from resource file into spring bean. i defined the place holder for resource file in the applicacationContext.xml.</p> <pre><code>&lt;context:property-placeholder location="file:///${MRAPOR_PROPPATH}mRapor.properties" /&gt; </code></pre> <p>I can inject values to beans which is declared in the applicationContext.xml like : </p> <pre><code>&lt;bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" &gt; &lt;property name="jndiName" value="${database.jndiName}" /&gt; &lt;property name="lookupOnStartup" value="false" /&gt; &lt;property name="cache" value="true" /&gt; &lt;property name="proxyInterface" value="javax.sql.DataSource" /&gt; &lt;/bean&gt; </code></pre> <p>This works well. However, i can not inject values if i declare beans with spring annotations. </p> <pre><code>@Component("SecurityFilter") public class SecurityFilter implements Filter { public static final String USER = "USER_SESSION_KEY"; public static final String CENTRIFY_USERNAME_KEY = "REMOTE_USERNAME"; @Value("${url.logout}")//I get error here !!!! private String logoutUrl; //proper setters and getters. } </code></pre> <p>Do you have any idea why i can not access values inside the beans declared using annotations.</p> <p>Here is my exception </p> <pre><code>weblogic.application.ModuleException: at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) Truncated. see log file for complete stacktrace Caused By: java.lang.IllegalArgumentException: Could not resolve placeholder 'url.logout' in string value [${url.logout}] at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173) at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125) at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:255) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:748) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:745) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload