Problem with dependency injection
Hi all,
Let me try to explain my problem. I have a 3-tier java framework. I use ICEfaces and spring.
TestBean
TestService (business layer)
TestDao (data layer)
In my home.xhtml:
<ice:outputText value="#{testBean.testString}"/>
TestBean:
public class TestBean implements Serializable {
private static final long serialVersionUID = 1L;
private TestService testService;
private String testString;
* getters and setters, normal stuff *
TestServiceImpl:
public class TestServiceImpl implements TestService {
private TestDao testDao;
* getters and setters, normal stuff *
public String getTestString() {
return testDao.getTestString();
}
applicationContext.xml:
<bean id="testService" class="be.test.TestServiceImpl">
<property name="testDao" ref="testDao"/>
</bean>
<bean id="testDao" class="be.test.TestDaoImpl"/>
Ok, was is my problem. If I start my tomcat server, the console shows me that the testDao is set, so this works. But when I run my application, #{testBean.testString} calls the getTestString() in TestServiceImpl and it will use the testDao, and now this testDao is null, so I get a nullpointerexception. What am I doing wrong?
Thx