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:
and when this bean is created in one of my classes (bean definitionCode:<bean id="usernameService" class="service.UsernameService" scope="session" > <aop:scoped-proxy /> </bean>
as such:Code:<bean id="testController" class="controller.TestController" />
it works absolutely fine. However, when I try and do the same in another class, LogController:Code:@Autowired UsernameService uns;
then it does not work, and I get the following error:Code:<bean id="logController" class="controller.LogController" />
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.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 have Googled this extensively and have found many 'solutions', however as yet none of them have worked. I also posted this exact question on stackoverflow, however none of the responses have helped me solve the issue.
Thanks! James



Reply With Quote