title: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class
body: <p>I am doing spring login application. When I run the application on WAS server I am getting some exceptions. Errors</p>
  
  <blockquote>
    <p>org.springframework.web.servlet.FrameworkServlet initServletBean Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xyzAccessDao' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [services.ap.in.xyz.dao.impl.XYZAccessManagementDaoImpl]: Constructor threw exception; nested exception is java.lang.NullPointerException</p>
  </blockquote>
  
  <p>Controller Class</p>
  
  <pre><code>package services.ap.in.xyz.action;
  
  @Controller 
  public class XYZLoginAction {
  
  
    XYZAccessManagementDaoImpl xyzAccessDao;
  
    @RequestMapping("/login")  
    public ModelAndView processAction(HttpServletRequest request,HttpServletResponse res) {
  
          String loggedInUserId="";
          String pwd="";
          String NotesId = null;
          boolean authFlag=false;
  
  
        if (request.getParameter("loginSubmit") != null ){
        System.out.println(" processAction :: loginSubmit action"); 
  
        try{
            loggedInUserId = (String) request.getParameter("userName");
            pwd     = (String) request.getParameter("password");
  
            if(loggedInUserId!=null &amp;&amp; !loggedInUserId.equalsIgnoreCase("")&amp;&amp;pwd!=null &amp;&amp; !pwd.equalsIgnoreCase(""))
              {
  
                  NotesId = xyzAccessDao.getNotesId(loggedInUserId);
                   String message = "HELLO no role for "+NotesId;  
                    return new ModelAndView("welcome", "message", message);       
              }
                      else{
                       return new ModelAndView("errorpage", "message","Sorry, username or password error");  
                      }
  
                  }
  
              }
        }catch (Exception e) {
            System.out.println(" processAction :: Exception ::"+e.getMessage()+e.getStackTrace());
        }
                 return new ModelAndView("errorpage", "message","Sorry, username or password error");  
  }
  </code></pre>
  
  <p>DAO Interface    </p>
  
  <pre><code>package services.ap.in.xyz.dao;
  
  public interface XYZAccessManagementDao {
      public String getNotesId(String userId) throws Exception;   
  }
  </code></pre>
  
  <p>DAO Impl</p>
  
  <pre><code>package services.ap.in.xyz.dao.impl;
  
  import services.ap.in.xyz.action.XYZLoginAction;
  import services.ap.in.xyz.dao.XYZAccessManagementDao;
  
  public class XYZAccessManagementDaoImpl implements XYZAccessManagementDao{
  
      @Override
      public String getNotesId(String loggedInUserId) throws Exception {
          System.out.println(" getNotesId() :: Entered." + loggedInUserId);
          String notesId = "";
          try {
             // get notesID
              }
          } catch (Exception e) {
  
          }
          return notesId;
   }
  </code></pre>
  
  <p>login.jsp</p>
  
  <pre><code> &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt;
      &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
      &lt;html&gt;
          &lt;head&gt;
              &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
              &lt;title&gt;Login&lt;/title&gt;
          &lt;/head&gt;
          &lt;body&gt;
               &lt;form action="login.html" method="post"&gt;  
                  Name:&lt;input type="text" name="userName"/&gt;&lt;br/&gt;  
                  Password:&lt;input type="password" name="password"/&gt;&lt;br/&gt;  
                           &lt;input type="submit" value="login" name="loginSubmit"/&gt;  
              &lt;/form&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>spring-servlet.xml</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:p="http://www.springframework.org/schema/p"  
      xmlns:context="http://www.springframework.org/schema/context"  
      xsi:schemaLocation="http://www.springframework.org/schema/beans  
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  http://www.springframework.org/schema/context  
  http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;  
      &lt;context:component-scan  base-package="services.ap.in.gbsgdbcms.action" /&gt;  
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;  
          &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;  
          &lt;property name="suffix" value=".jsp" /&gt;  
      &lt;/bean&gt;  
       &lt;bean id="bcmAccessDao" class="services.ap.in.xyz.dao.impl.XYZAccessManagementDaoImpl" /&gt;  
  &lt;/beans&gt;  
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
      &lt;display-name&gt;LoginExample&lt;/display-name&gt;
      &lt;servlet&gt;  
      &lt;servlet-name&gt;spring&lt;/servlet-name&gt;  
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;  
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;  
  &lt;/servlet&gt;  
  &lt;servlet-mapping&gt;  
      &lt;servlet-name&gt;spring&lt;/servlet-name&gt;  
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;  
  &lt;/servlet-mapping&gt;  
  &lt;/web-app&gt;
  </code></pre>