title: Declaration of beans in applicationContext.xml
body: <p>I have a question regarding declaration of classes in <strong>applicationContext.xml</strong></p>
  
  <p>In <strong>applicationContext.xml</strong> do we need to specify all the classes from the application?
  E.g.
  In my small web application I have a <strong>Entity</strong> class, <strong>Service</strong> class and <strong>DAO</strong> class. So currently it is defined as</p>
  
  <pre><code>&lt;!-- Beans Declaration --&gt;
      &lt;bean id="Employees"
          class="net.test.model.Employees" /&gt;
  
   &lt;!-- User Service Declaration --&gt;
      &lt;bean id="
          EmployeeService" class="net.test.employees.service.EmployeeService"&gt;
          &lt;property name="employeesDAO" ref="EmployeeDAOImpl" /&gt;
      &lt;/bean&gt;
  
   &lt;!-- User DAO Declaration --&gt;
      &lt;bean id="EmployeeDAO" class="net.test.employee.dao.EmployeeDAOImpl"&gt;
          &lt;property name="sessionFactory" ref="SessionFactory" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>So if I have multiple entity, service and dao classes do I need to mention all those classes in <code>applicationContext.xml</code>?</p>
  
  <p>Any insight into this is highly appreciable.</p>
  
  <p>Regards</p>
  
  <p>Update 1</p>
  
  <p>ManagedBean</p>
  
  <pre><code>@ManagedBean(name="empMB")
  @Named
  @Scope("request")
  public class EmployeesManagedBean implements Serializable {
  </code></pre>
  
  <p>and I have Inject annotation</p>
  
  <pre><code>@Inject
  EmployeesService employeesService;
  </code></pre>
  
  <p>In EmployeesService I have annotations like</p>
  
  <pre><code>@Named
  public class EmployeesService implements IEmployeesService {
  
  @Inject
  EmployeesDAO employeesDAO;
  
  @Override
  public List&lt;Employees&gt; getEmployees() {
      return getEmployeesDAO().getEmployees();
  }
  </code></pre>
  
  <p>and finally in applicationContext.xml I have </p>
  
  <pre><code>&lt;context:component-scan base-package="net.test" /&gt;
  </code></pre>
  
  <p>Now the problem is when I run my application I am getting </p>
  
  <pre><code>java.lang.NullPointerException at
  net.test.managed.bean.EmployeesManagedBean.getEmpList(EmployeesManagedBean.java:53)
  </code></pre>
  
  <p>What am I doing wrongly to get <strong>nullpointer exception</strong>?</p>