
Hi all, I have a problem with Spring dependency injection. The scenario is as follows: I have a number of Data Access Objects (DAOs), Service Classes, and Web Layer Controllers. Data exchange between the different layers takes place via Sping DI. Injecting a DAO directly to my Controllers works fine but this brings in design issues. So I have included the Service layer that undertakes additional business logic before sending the data to the DAOs. The implementation of the service layer includes a base service class inherited by other classes: i.e: public class ServiceImpl implements Service{ (1)protected Dao<Customer, String> customerDao private void setCustomerDao(Dao<Customer, String> customerDao){ this.customerDao = customerDao; } ............ ............. ...... } public class CustomerServiceImpl extends ServiceImpl implements CustomerService{ private void getCustomer(String customerId){ (2) customerDao.getCustomerById(customerId); } ......................... .......................... ........................ } The customerDao in ServiceImpl injected by Spring as follows <bean id="serviceImpl" class="ke.co.x.x.ServiceImpl"> <property name="customerDao" ref="customerDao"/> </bean> <bean id="customerServiceImpl" class="ke.co.x.x.CustomerServiceImpl"> </bean> Every other dependency is taken care of in Spring's applicationContext.xml config file in a similar manner. When tested using JUnit or on the browser, a NullPointerException is thrown at (2). The DAO defined in the superclass is null in the subclass. This raises the question whether Spring's DI supports normal Java class inheritance and if it does, is there any special config required for this?