Bean is not getting Autowired
<p>Hi Friends i am creating a simple application using Spring and JPA over Hibernate but i am getting a Null Pointer Exception while running the app as the beans are not getting initialised.Below is my <code>application-context.xml</code></p>

<pre><code>&lt;beans&gt;
    &lt;mvc:annotation-driven/&gt;
    &lt;bean id="entityManagerFactoryBean" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
        &lt;property name="dataSource" ref="dataSource" /&gt;
        &lt;property name="packagesToScan" value="com.sms.examination.entity.*" /&gt;
        &lt;/property&gt;
        &lt;property name="jpaProperties"&gt;
            &lt;props&gt;
                &lt;prop key="hibernate.hbm2ddl.auto"&gt;validate&lt;/prop&gt;
                &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
            &lt;/props&gt;
        &lt;/property&gt;
    &lt;/bean&gt;
    &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
        &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
        &lt;property name="url" value="jdbc:mysql://localhost:3306/examination" /&gt;
        &lt;property name="username" value="root" /&gt;
        &lt;property name="password" value="" /&gt;
    &lt;/bean&gt;
    &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
        &lt;property name="entityManagerFactory" ref="entityManagerFactoryBean" /&gt;
    &lt;/bean&gt;
    &lt;tx:annotation-driven/&gt;
&lt;/beans&gt;
</code></pre>

<p>NameDao Interface :-</p>

<pre><code>package com.sms.examination.dao;

import java.util.List;
import com.sms.examination.entity.Name;

public interface NameDao  {
    public List&lt;Name&gt; findAll();
}
</code></pre>

<p>Implementation</p>

<pre><code>package com.sms.examination.dao;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.sms.examination.entity.Name;

@Repository
@Transactional
@Component
public class NamedaoImpl implements NameDao 
{
    @PrsistenceContext
    private EntityManager entityManagerFactoryBean;

    public List&lt;Name&gt; findAll() {
        if(entityManagerFactoryBean==null)
        {
            System.out.println("manager is null");
        }
        else
            System.out.println("manager is not null");

         List&lt;Name&gt; names = entityManagerFactoryBean.createQuery("select s from Name s",Name.class).getResultList();
            return names;
    }
}
</code></pre>

<p>Controller      </p>

<pre><code> package com.sms.examination.controller;

    import java.util.*;
    import com.sms.examination.dao.NameDao;
    import com.sms.examination.dao.NamedaoImpl;
    import com.sms.examination.entity.Name;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    public class NameController {
            @Autowired
            private NameDao namedao;
            @Autowired
            private NamedaoImpl name;
            public void getNames(){
                List&lt;Name&gt; namelist=new ArrayList&lt;Name&gt;();
                if(namedao==null)
                {
                    System.out.println("name doa is null");
                }
                namelist=namedao.findAll();
                Iterator&lt;Name&gt; it=namelist.iterator();
                while(it.hasNext())
                {
                    System.out.println(it.hasNext());
                }
            }
            public static void main(String[] args) {
                ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:application-context.xml");
                NameController names=new NameController();
                names.getNames();
            }
    }
</code></pre>

<p>While running the Controller class i am getting the below output.Please help
name doa is <code>null</code> which is because the <code>NameDao</code> class has not been initailised.</p>