I have been working on my first Spring project, and I've come across an annoying problem.
I have a class called 'UsernameService' which is configured as a bean in the dispatcher-servlet.xml:
<bean id="usernameService" class="service.UsernameService" scope="session" >
<aop:scoped-proxy />
</bean>
and when this bean is created in one of my classes (bean definition:)
<bean id="testController" class="controller.TestController" />
as such:
@Autowired
UsernameService uns;
it works absolutely fine. However, when I try and do the same in another class, LogController:
<bean id="logController" class="controller.LogController" />
then it does not work, and I get the following error:
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/flexitime] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException
I've managed to (I believe) ascribe this error to the fact that uns is never actually set/created and remains as null inside LogController.
I have Googled this extensively and have found many 'solutions', however as yet none of them have worked.
Thanks! James