Hi folks,
i have the following problem:
I define a bean in my applicationContext:
In a junit test the loading of the applicationContext works well until another bean will be initialized through the context: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 my understanding if I use the following code, the collectorBean should wait until the applicationProperties are initilized and ready for injection.Code:<bean id="collectorBean" name="collectorBean" class="de.test.collectorBean" depends-on="applicationProperties" />
But when I start loading the applicationContext, I get a NullPointerException because applicationProperties is NULL.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"); } }
Any suggestions what can be wrong?
Cheers and thanks in advance
Peter


Reply With Quote