I am trying to inject a dependency into a class. The class is named TechnicianViewHelper and looks something like this:
Since this is a webapp, the related bean definitions in applicationContext.xml look something like this:Code:public class TechnicianViewHelper { private TechnicianService technicianService; @Required public void setTechnicianService(TechnicianService technicianService) { this.technicianService = technicianService; } private int technicianId; public void setTechnicianId(int technicianId) { this.technicianId = technicianId; } public List<Technician> getUnapprovedTechnicians() { List<Technician> unapprovedTechnicianList = technicianService.getUnapprovedTechnicians(); return unapprovedTechnicianList; //return technicianService.getUnapprovedTechnicians(); } }
I'm reasonably sure that technicianService is working correctly: my LoginAction defined in action-servlet.xml pulls the same service and works fine.HTML Code:<bean id="technicianService" class="mil.af.amc.projecttracker.service.TechnicianServiceImpl"> <property name="technicianDao"> <ref bean="technicianDao" /> </property> <property name="personDao"> <ref bean="personDao" /> </property> <property name="gradeDao"> <ref bean="gradeDao" /> </property> <property name="baseDao"> <ref bean="baseDao" /> </property> <property name="organizationDao"> <ref bean="organizationDao" /> </property> <property name="officeSymbolDao"> <ref bean="officeSymbolDao" /> </property> <property name="permissionDao"> <ref bean="permissionDao" /> </property> <property name="projectDao"> <ref bean="projectDao" /> </property> </bean> <bean id="technicianViewHelper" class="mil.af.amc.projecttracker.web.viewhelpers.TechnicianViewHelper" depends-on="technicianService"> <property name="technicianService"> <ref bean="technicianService" /> </property> </bean>
I've also tried, in desperation, switching the technicianViewHelper to be autowired by name. But when I attempt to debug the TechnicianViewHelper class, the debug shows the technician service to be null, and a NullPointerException is thrown.
Am I just making a stupid mistake here?
Jason


Reply With Quote

