Q: Not able to use injected properties in spring beans below is my spring-database.xml file. I can use sessionFactory in userDao. I also can use userDao in myUserDetailsService class. but when i try to use sessionFactory in registrationDao it gives me NullPointerException. same happens when i try to use registrationDao in registrationService service.
i am getting confused. please help.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">

    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/myds" />
    <property name="username" value="root" />
    <property name="password" value="mypass" />
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="com.findsuvidha.web.entity"/>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
            <prop key="hibernate.format_sql">true</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
</bean>

<bean id="userDao" class="com.findsuvidha.web.dao.UserDaoImpl">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="myUserDetailsService" class="com.findsuvidha.web.service.MyUserDetailsService">
    <property name="userDao" ref="userDao" />
</bean>

<bean id="registrationDao" class="com.findsuvidha.web.dao.RegistrationDaoImpl">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="registrationService" class="com.findsuvidha.web.service.RegistrationService">
    <property name="registrationDao" ref="registrationDao" />
</bean>
<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="get*" read-only="true" />
        <tx:method name="find*" read-only="true" />
        <tx:method name="*" />
    </tx:attributes>
</tx:advice>

<aop:config>
    <aop:pointcut id="userServicePointCut"
        expression="execution(* com.findsuvidha.web.service.*Service.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="userServicePointCut" />
</aop:config>

</beans>

Edit1:-Dao and DaoImpl which are able to use injected property
UserDao.java
      package com.findsuvidha.web.dao;

    import com.findsuvidha.web.entity.LoginMaster;

    public interface UserDao {

        LoginMaster findByUserName(String username);

    }

UserDaoImpl.java    
      package com.findsuvidha.web.dao;

    import java.util.ArrayList;
    import java.util.List;

    import org.hibernate.SessionFactory;

    import com.findsuvidha.web.entity.LoginMaster;

    public class UserDaoImpl implements UserDao {

        private SessionFactory sessionFactory;

        @SuppressWarnings("unchecked")
        public LoginMaster findByUserName(String email) {

            List<LoginMaster> users = new ArrayList<LoginMaster>();

            users = getSessionFactory().getCurrentSession().createQuery("from LoginMaster where email=?")
                    .setParameter(0, email).list();

            if (users.size() > 0) {
                return users.get(0);
            } else {
                return null;
            }

        }

        public SessionFactory getSessionFactory() {
            return sessionFactory;
        }

        public void setSessionFactory(SessionFactory sessionFactory) {
            this.sessionFactory = sessionFactory;
        }

    }


Dao and DaoImpl which are not able to use injected property

RegistrationDao.java
  package com.findsuvidha.web.dao;

    import com.findsuvidha.web.transferobject.NewUser;

    public interface RegistrationDao {

        void insertUser(NewUser user);
    }

RegistrationDaoImpl.java
      package com.findsuvidha.web.dao;

    import org.hibernate.SessionFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;

    import com.findsuvidha.web.entity.LoginMaster;
    import com.findsuvidha.web.entity.UserDetail;
    import com.findsuvidha.web.transferobject.NewUser;


    public class RegistrationDaoImpl implements RegistrationDao{


        private SessionFactory sessionFactory;
        private LoginMaster loginUser = new LoginMaster();
        private UserDetail userDetail = new UserDetail();
        @Override
        public void insertUser(NewUser user) {

            System.out.println("entered dao impl");
            userDetail.setEmail(user.getEmail());
            userDetail.setFirstName(user.getFirstName());
            userDetail.setLastName(user.getLastName());
            userDetail.setMobileNo(user.getMobileNumber());

            loginUser.setEmail(user.getEmail());
            loginUser.setPassword(user.getPassword());
            loginUser.setRoleFlag("ROLE_USR");
            loginUser.setUserDetail(userDetail);
            System.out.println("before session save");
            getSessionFactory().getCurrentSession().save(loginUser);

        }


        public SessionFactory getSessionFactory() {
            return sessionFactory;
        }


        public void setSessionFactory(SessionFactory sessionFactory) {

            this.sessionFactory = sessionFactory;
        }
    }

