Injection of Properties fails
Hi folks,
i have the following problem:
I define a bean in my applicationContext:
Code:
<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>file:/etc/acodyn/collector.properties</value>
</list>
</property>
</bean>
In a junit test the loading of the applicationContext works well until another bean will be initialized through the context:
Code:
<bean id="collectorBean" name="collectorBean" class="de.test.collectorBean" depends-on="applicationProperties" />
In my understanding if I use the following code, the collectorBean should wait until the applicationProperties are initilized and ready for injection.
Code:
public class CallCollectorProviderObserverBean implements ProviderObserver{
final Logger logger = LoggerFactory.getLogger(CallCollectorProviderObserverBean.class);
Condition conditionInService = new Condition();
@Autowired
private Properties applicationProperties;
public collectorBean() {
initialize();
}
private void initialize(){
String host = applicationProperties.getProperty("host");
String user = applicationProperties.getProperty("user");
}
}
But when I start loading the applicationContext, I get a NullPointerException because applicationProperties is NULL.
Any suggestions what can be wrong?
Cheers and thanks in advance
Peter