I have a jsp login page for identifying users. To configure JdbcTemplate , I set up its properties with spring under "WEB-INF/applicationContext.xml" , so for loading spring context , i added some tags in web.xml . But , autowiring jdbcTemplate bean in UserDao class is causing a NullPointerException !
applicationContext.xml
 <context:annotation-config />
 <context:component-scan base-package="com.firstapp.dao"/>
 <bean id="datasource" 
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
     <property name="driverClassName" 
     value="oracle.jdbc.driver.OracleDriver"  />  
     <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" />  
     <property name="username" value="system" />  
     <property name="password" value="oracle" />  
 </bean>  
<bean id="jdbcTemplate" 
      class="org.springframework.jdbc.core.JdbcTemplate">  
      <property name="dataSource" ref="datasource"></property>  
 </bean>  
class DAO
 public class UserDAO 
  {
   @Autowired
   private JdbcTemplate jdbcTemplate;
   ....}
class Service
  public class UserService  
   {
      private UserDAO  userDAO  = new UserDAO ();       
    ....}
web.xml
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
  <listener-class>
     org.springframework.web.context.ContextLoaderListener
  </listener-class>
</listener>
 
    