Spring @Autowired NullPointerException
<p><strong>This is my controller class</strong></p>

<p>I have a problem when I persist data in mysql then
@autowired field is null. I use spring,jpa,and primefaces</p>

<pre><code> package com.netizenbd.controller;

    import javax.faces.bean.ManagedBean;
    import org.apache.log4j.Logger;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Controller;
    import com.netizenbd.dao.StudentDao;
    import com.netizenbd.domain.Student;

    @ManagedBean
    @Controller
    @Scope("session")
    public class StudentMB {

    final static Logger logger = Logger.getLogger(StudentMB.class);

    @Autowired
    public StudentDao studentDao;
    private Student student;

    public void saveStudent(){
        try {
            studentDao.persist(student);
        } catch (Exception e) {
            logger.debug("This is debug :" + e);
            logger.error("This is error : " + e);
            logger.fatal("This is fatal : " + e);
            e.printStackTrace();
        }
    }
    public Student getStudent() {
        if(student==null){
            student = new Student();
        }
        return student;
    }
    public void setStudent(Student student) {
        this.student = student;
    }
    }
</code></pre>

<p><strong>This is my service class</strong></p>

<pre><code>package com.netizenbd.service;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.netizenbd.dao.StudentDao;
import com.netizenbd.domain.Student;

@Transactional
@Component
public class StudentService extends
EntityService&lt;Student&gt; implements StudentDao{

}
</code></pre>

<p><strong>This is my DAO interface</strong></p>

<p>Whis is @autowired in controller</p>

<pre><code> package com.netizenbd.dao;

    import com.netizenbd.domain.Student;

    public interface StudentDao extends EntityDao&lt;Student&gt;{

    }
</code></pre>

<p><strong>This is my applicationContext.xml file</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
 &lt;beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:context="http://www.springframework.org/schema/context"                     
 xmlns:jdbc="http://www.springframework.org/schema/jdbc"
 xmlns:mvc="http://www.springframework.org/schema/mvc"     
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd   
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-4.2.xsd   
 http://www.springframework.org/schema/jdbc
 http://www.springframework.org/schema/jdbc/spring-jdbc-4.2.xsd 
 http://www.springframework.org/schema/mvc
 http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd 
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-4.2.xsd"&gt;

&lt;!-- Scan for all of Spring components such as Spring Service --&gt;
&lt;context:component-scan base-package="com.netizenbd"&gt;
&lt;/context:componentscan&gt;  
&lt;context:annotation-config/&gt;
&lt;!-- Import all other context files --&gt;
&lt;import resource="classpath:META-INF/spring/applicationContext-*.xml" /&gt;

&lt;!-- MVC annotation Driven --&gt;
&lt;mvc:annotation-driven /&gt;
&lt;/beans&gt;
</code></pre>

<p><strong>The exception</strong></p>

<pre><code>     java.lang.NullPointerException
     at com.netizenbd.controller.StudentMB.saveStudent(StudentMB.java:26)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
     at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    javax.faces.component.MethodBindingMethodExpressionAdapter
   .invoke(MethodBindingMethodExpressionAdapter.java:87)
    org.springframework.faces.webflow.FlowActionListener.processAction(FlowActio
    org.springframework.faces.model.SelectionTrackingActionListener.
    processAction(SelectionTrackingActionListener.java:64)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at  com.sun.faces.lifecycle.InvokeApplicationPhase
    .execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
</code></pre>

<p>I don't know what I'm doing wrong.
 Please let me know what wrong with this configuration.</p>