title: BeanInstantiationException: Could not instantiate bean class
body: <p>I am having troubles while trying execute my Spring MVC application on Tomcat 7.</p>
  
  <p>Here is my <strong>DSLRServletController</strong>:</p>
  
  <pre><code> import main.java.com.springapp.mvc.dao.DSLRDAO;
      import main.java.com.springapp.mvc.model.DSLR;
      import main.java.com.springapp.mvc.pckg.DSLRForm;
      import main.java.com.springapp.mvc.pckg.DSLRValidaor;
      import org.apache.log4j.Logger;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Controller;
      import org.springframework.ui.Model;
      import org.springframework.web.bind.annotation.ModelAttribute;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RequestMethod;
      import org.springframework.web.bind.annotation.RequestParam;
  
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      import java.io.IOException;
      import java.util.*;
  
      @Controller
      public class DSLRServletController extends HttpServlet {
          static Logger logger = Logger.getLogger(DSLRServletController.class);
  
          private DSLRDAO dslrDAO;
  
         /* request.setCharacterEncoding("UTF-8");
          response.setContentType("text/html; charset=utf-8");
          List list = getActions(request, response);
          response.setContentType("text/html; charset=UTF-8");*/
  
          //@Autowired // need?
          public DSLRServletController() {
              this.dslrDAO = new DSLRDAO();
          }
  
          public void init() {logger.error("DSLRServlet.init(): just started"); }
          /*
                  /s                                    GET
                  /s?id=1                               GET
                  /s?action=save                        POST
                  /dslrservice?id=1&amp;tm=&lt;timestamp&gt;      GET
           */
      @RequestMapping(value = "/s", method = RequestMethod.GET)
      public String showHTMLResponse(@ModelAttribute("dslrs") DSLR dslrs[],
                                     @ModelAttribute("dslr") DSLR dslr,
                                     @ModelAttribute("dslrErrors") HashMap dslrErrors,
                                     @ModelAttribute ("dslrform") DSLRForm dslrForm,
                                     @RequestParam("id") String paramId,
                                     @RequestParam("action") String paramAction,
                                     Model model){
  
          if(paramId == null || paramId.equals("")){
              //show_all_dslrs
              dslrs = getAllDslrs();    // DSLR adslrs[] -&gt; to MODEL; HOW?
              //getServletConfig().getServletContext().getRequestDispatcher("/dslrs.jsp").forward(request, response);
             return "dslrs";
          }else{
              //show_this_dslr;
              HashMap&lt;String,Object&gt; dslrHashMap = getDSLRById(paramId);
              dslr = (DSLR) dslrHashMap.get("dslr");
              dslrForm = (DSLRForm)dslrHashMap.get("dslrForm");
              dslrErrors = (HashMap)dslrHashMap.get("dslrErrors");
  
                  if(dslr != null){
      //                getServletConfig().getServletContext().getRequestDispatcher("/dslr.jsp").forward(request, response);
                      return "dslr";
                  }
  
                  else{
      //                getServletConfig().getServletContext().getRequestDispatcher("/error.jsp").forward(request, response);
                      return "error";
                  }
  
  
          }
      }
  
      @RequestMapping(value = "/s", method = RequestMethod.POST)
      public String showHTMLResponsePOST(@ModelAttribute("dslrs") DSLR dslrs[],
                                     @ModelAttribute("dslrErrors") HashMap&lt;?,?&gt; dslrErrors,
                                     @ModelAttribute ("dslrform") DSLRForm dslrForm,
  
                                     @RequestParam("id") String paramId,
                                     @RequestParam("action") String paramAction,
                                     @RequestParam("dslr_model") String paramModel,
                                     @RequestParam("price") String paramPrice,
                                     @RequestParam("description") String paramDescription,
                                     Model model){
          int iStatusCode = 0;
          if(paramAction.equals("save") )
              iStatusCode = saveDSLR(paramId, paramModel, paramPrice, paramDescription, dslrErrors, dslrForm);    // POST
  
          return "dslrs";
  
      }
  
          private int saveDSLR(String paramId,
                               String paramModel,
                               String paramPrice,
                               String paramDescription,
                               HashMap&lt;?,?&gt; context_dslrErrors,
                               DSLRForm context_dslrForm
                               ) {
              int byte0 = 1;
              try {
  
                  DSLRValidaor dslrValidaor = new DSLRValidaor();
  
                  DSLRForm dslrForm = new DSLRForm();
                  dslrForm.setDslrId(paramId);
                  dslrForm.setModel(paramModel);
                  dslrForm.setPrice(paramPrice);
                  dslrForm.setDescription(paramDescription);
  
                  HashMap hashmap = dslrValidaor.Validate(dslrForm);
                  if(hashmap.size() &gt; 0) {
                      context_dslrForm = dslrForm;
                      context_dslrErrors = hashmap;
                      byte0 = -1;
                  } else{
                      DSLRDAO planedao = new DSLRDAO();
                      DSLR dslr = new DSLR();
                      dslr.setDslrId(Integer.parseInt(paramId));
                      dslr.setModel(paramModel);
                      dslr.setPrice(Integer.parseInt(paramPrice));
                      dslr.setDescription(paramDescription);
                      planedao.update(dslr);
                  }
              }
              catch(Exception exception)
              {
                  logger.error((new StringBuilder()).append("DSLRServlet.saveDSLR():").append(exception.getMessage()).toString());
                  byte0 = -1;
              }
              return byte0;
  
          }
  
          private DSLR[] getAllDslrs(){
              DSLR adslrs[] = null;
              try
              {
                  DSLRDAO DSLRDAO = new DSLRDAO();
                  adslrs = (DSLR[])DSLRDAO.findAll();
              }
              catch(Exception exception)
              {
                  logger.error((new StringBuilder()).append("PlaneServlet.getAllPlanes():").append(exception.getMessage()).toString());
              }
      //        request.setAttribute("dslrs", adslrs);
              return adslrs;
          }
  
          private HashMap&lt;String, Object&gt; getDSLRById(String s)
          {
              HashMap&lt;String,Object&gt; map = new HashMap&lt;String, Object&gt;();
  
              DSLR dslr = null;
              try {
                  int i = Integer.parseInt(s);
                  DSLRDAO DSLRDAO = new DSLRDAO();
                  dslr = (DSLR)DSLRDAO.findById(i);
  
                  DSLRForm dslrForm = new DSLRForm();
                  dslrForm.setDslrId(Integer.toString(dslr.getDslrId()));
                  dslrForm.setModel(dslr.getModel());
                  dslrForm.setPrice(Integer.toString(dslr.getPrice()));
                  dslrForm.setDescription(dslr.getDescription());
  
  
                  map.put("dslr", dslr);
                  map.put("dslrform", dslrForm);
                  map.put("dslrErrors", new HashMap());
  
      //            request.setAttribute("dslrform", dslrForm);
      //            HashMap hashmap = new HashMap();
      //            request.setAttribute("dslrErrors", hashmap);
              }
              catch(Exception exception)
              {
                  logger.error((new StringBuilder()).append("DSLRServlet.getDSLRById():").append(exception.getMessage()).toString());
              }
              return map;
          }
      }
  </code></pre>
  
  <p><strong>DSLRServletController-servlet.xml :</strong> </p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         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="main.java.com.springapp.mvc" /&gt;
  
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/pages/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
      &lt;!--&lt;bean name="/s" class="main.java.com.springapp.mvc.controller.DSLRServletController"/&gt;--&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>DSLRDAO:</strong></p>
  
  <pre><code>package main.java.com.springapp.mvc.dao;
  
  import main.java.com.springapp.mvc.model.DSLR;
  import main.java.com.springapp.mvc.util.DbUtil;
  import org.apache.log4j.Logger;
  
  import java.sql.*;
  import java.util.ArrayList;
  import java.util.List;
  
  public class DSLRDAO {
  
      Connection connection = null;
  //    static Logger logger = Logger.getLogger(ttu/idu0200/db/PlaneDAO);
      public DSLRDAO() {
          connection = DbUtil.getConnection();
      }
  
      public DSLR[] findAll() {
  //        connection = DbUtil.getConnection();
          List&lt;DSLR&gt; dslrs = new ArrayList&lt;DSLR&gt;();
          try {
              Statement statement = connection.createStatement();
              ResultSet rs = statement.executeQuery("select * from DSLR");
              while (rs.next()) {
                  DSLR dslr = new DSLR();
                  dslr.setDslrId(rs.getInt("dslrid"));
                  dslr.setModel(rs.getString("model"));
                  dslr.setPrice(rs.getInt("price"));
                  dslr.setDescription(rs.getString("description"));
                  dslrs.add(dslr);
              }
          } catch (SQLException exception) {
              Logger.getLogger(DSLRDAO.class).error((new StringBuilder()).append("DSLRDAO:").append(exception.getMessage()).toString());
          }finally {
  //            DbUtil.close();
          }
  
          return dslrs.toArray(new DSLR[dslrs.size()]);
      }
  
      public DSLR findById(int dslrId){
  //        connection = DbUtil.getConnection();
          DSLR dslr = new DSLR();
  
          try{
              PreparedStatement preparedStatement = connection.prepareStatement("select * from DSLR where dslrid=?");
              preparedStatement.setInt(1, dslrId);
              ResultSet resultSet = preparedStatement.executeQuery();
  
              if(resultSet.next()){
                  dslr.setDslrId(resultSet.getInt("dslrid"));
                  dslr.setModel(resultSet.getString("model"));
                  dslr.setPrice(resultSet.getInt("price"));
                  dslr.setDescription(resultSet.getString("description"));
              }
          } catch (SQLException exception) {
              Logger.getLogger(DSLRDAO.class).error((new StringBuilder()).append("DSLRDAO:").append(exception.getMessage()).toString());
          } finally {
  //            DbUtil.close();
  //            connection = null;
          }
          return dslr;
      }
      public void update(DSLR dslr){
  //        connection = DbUtil.getConnection();
       try{
           PreparedStatement preparedStatement  =
                   connection.prepareStatement("update dslr set model=?, price=?, description=?" + " where dslrid=?");
  
           preparedStatement.setString(1, dslr.getModel());
           preparedStatement.setInt(2, dslr.getPrice());
           preparedStatement.setString(3, dslr.getDescription());
           preparedStatement.setInt(4, dslr.getDslrId());
  
           preparedStatement.executeUpdate();
  
       } catch (SQLException exception) {
           Logger.getLogger(DSLRDAO.class).error((new StringBuilder()).append("DSLRDAO:").append(exception.getMessage()).toString());
       } finally {
  //        DbUtil.close();
  //        connection = null;
       }
  
      }
  }
  </code></pre>
  
  <p><strong>web.xml:</strong></p>
  
  <pre><code>&lt;web-app version="2.4"
      xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
  
      &lt;display-name&gt;Spring MVC Application&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;mvc-dispatcher&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;mvc-dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Errors:</strong></p>
  
  <pre><code>HTTP Status 500 - Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [[Lmain.java.com.springapp.mvc.model.DSLR;]: No default constructor found; nested exception is java.lang.NoSuchMethodException: [Lmain.java.com.springapp.mvc.model.DSLR;.&lt;init&gt;()
  
  type Exception report
  
  message Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [[Lmain.java.com.springapp.mvc.model.DSLR;]: No default constructor found; nested exception is java.lang.NoSuchMethodException: [Lmain.java.com.springapp.mvc.model.DSLR;.&lt;init&gt;()
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [[Lmain.java.com.springapp.mvc.model.DSLR;]: No default constructor found; nested exception is java.lang.NoSuchMethodException: [Lmain.java.com.springapp.mvc.model.DSLR;.&lt;init&gt;()
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:927)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  root cause
  
  org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [[Lmain.java.com.springapp.mvc.model.DSLR;]: No default constructor found; nested exception is java.lang.NoSuchMethodException: [Lmain.java.com.springapp.mvc.model.DSLR;.&lt;init&gt;()
      org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:108)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:770)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:363)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
      org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439)
      org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  root cause
  
  java.lang.NoSuchMethodException: [Lmain.java.com.springapp.mvc.model.DSLR;.&lt;init&gt;()
      java.lang.Class.getConstructor0(Class.java:2810)
      java.lang.Class.getDeclaredConstructor(Class.java:2053)
      org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:770)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:363)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
      org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439)
      org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <hr>
  
  <p><strong>UPADTE4:</strong></p>
  
  <p>the new <strong>DSLR class</strong> with default constructor still returns same errors</p>