title: Servlet.init() for servlet [dispatcher] threw exception
body: <p>i'm trying to access DAO class in another jar file , i have added it's dependency in my pom.xml, and trying to access it through my 'page controller' in present module, but i'm getting exception</p>
  
  <p>i tried checking the name in my component scan, checked the name of the autowired object</p>
  
  <p>dispatcher-servlet.xml</p>
  
  <pre><code>&lt;context:component-scan base-package="com.apurv.onlineshopping.controller"/&gt;
  &lt;context:component-scan base-package="com.apurv.shoppingbackend.daoImpl "/&gt;
  
  
  &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
   &lt;property name="prefix"  value="/WEB-INF/views/"&gt;&lt;/property&gt;
   &lt;property name="suffix"  value=".jsp"&gt;&lt;/property&gt;
  
  
  
   &lt;/bean&gt;    
  
   &lt;!-- loading static resources --&gt;
  &lt;mvc:annotation-driven&gt;&lt;/mvc:annotation-driven&gt;
  &lt;mvc:resources location="/assets/" mapping="/resources/**"&gt;&lt;/mvc:resources&gt;
  &lt;/beans&gt;        
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
           http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
           version="3.1"&gt;
    &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
    &lt;servlet&gt;
    &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>page controller</p>
  
  <pre><code>package com.apurv.onlineshopping.controller;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.servlet.ModelAndView;
  
  import com.apurv.shoppingbackend.dao.CategoryDAO;
  
  @Controller
  public class PageController {
  
      @Autowired
      private CategoryDAO categoryDao;
  
      @RequestMapping(value= {"/","/home","/index"})
      public ModelAndView index() {
          ModelAndView mv= new ModelAndView("page");
          mv.addObject("title","Home");
  
          //passing category list from back end
          mv.addObject("categories", categoryDao.list());
  
          mv.addObject("userClickHome",true);
          return mv;
      }
  
      @RequestMapping(value="/about")
      public ModelAndView about() {
          ModelAndView mv= new ModelAndView("page");
          mv.addObject("title","About Us");
          mv.addObject("userClickAbout",true);
          return mv;
      }
  
      @RequestMapping(value="/contact")
      public ModelAndView contact() {
          ModelAndView mv= new ModelAndView("page");
          mv.addObject("title","Contact Us");
          mv.addObject("userClickContact",true);
          return mv;
      }
  }
  </code></pre>
  
  <p>other jar DAO</p>
  
  <pre><code>package com.apurv.shoppingbackend.daoImpl;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.springframework.stereotype.Repository;
  
  import com.apurv.shoppingbackend.dao.CategoryDAO;
  import com.apurv.shoppingbackend.dto.Category;
  
  @Repository
  public class CategoryDAOImpl implements CategoryDAO{
  
      private static List&lt;Category&gt; categories=new ArrayList&lt;&gt;();
  
      static {
          Category category=new Category();
  
          //first category
          category.setId(1);
          category.setName("Televison");
          category.setDescription("this is a flat screen tv");
          category.setImageURL("CAT_1.png");
  
  
          categories.add(category);
  
  
          /*
           * //second category category=new Category(); category.setId(2);
           * category.setName("Mobile"); category.setDescription("this is a apple phone");
           * category.setImageURL("CAT_2.png");
           * 
           * 
           * categories.add(category);
           * 
           * //third category
           * 
           * category=new Category();
           * 
           * category.setId(3); category.setName("fridge");
           * category.setDescription("this is a double door fridge");
           * category.setImageURL("CAT_3.png");
           * 
           * 
           * categories.add(category);
           * 
           * //fourth category
           * 
           * category=new Category(); category.setId(4);
           * category.setName("washing machine");
           * category.setDescription("this is an automatic washing machine ");
           * category.setImageURL("CAT_4.png");
           * 
           * 
           * categories.add(category);
           * 
           */     
      }
  
      @Override
      public List&lt;Category&gt; list() {
          // TODO Auto-generated method stub
          return categories;
      }
  
  }
  </code></pre>
  
  <p>HTTP Status 500 – Internal Server Error
      Type Exception Report</p>
  
  <pre><code>Message Servlet.init() for servlet [dispatcher] threw exception
  
  Description The server encountered an unexpected condition that prevented it from fulfilling the request.
  
  Exception
  
  javax.servlet.ServletException: Servlet.init() for servlet [dispatcher] threw exception
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
      org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)
  Root Cause
  
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pageController' defined in file [C:\Users\apurv\fullStackPractice\shopping\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\onlineshopping\WEB-INF\classes\com\apurv\onlineshopping\controller\PageController.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.apurv.onlineshopping.controller.PageController] for resource metadata: could not find class that it depends on
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:526)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
      org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
      org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
      org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
      org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
      org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
      org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
      org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
      org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
      org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
      org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
      org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
      org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
      javax.servlet.GenericServlet.init(GenericServlet.java:158)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
      org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  </code></pre>
  
  <p>pom.xml where i have included the other module as  dependency</p>
  
  <pre><code>    &lt;project xmlns="http://maven.apache.org/POM/4.0.0" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
         http://maven.apache.org/maven-v4_0_0.xsd"&gt;
        &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
        &lt;groupId&gt;com.apurv&lt;/groupId&gt;
        &lt;artifactId&gt;onlineshopping&lt;/artifactId&gt;
        &lt;packaging&gt;war&lt;/packaging&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;name&gt;onlineshopping Maven Webapp&lt;/name&gt;
        &lt;url&gt;http://maven.apache.org&lt;/url&gt;
        &lt;properties&gt;
        &lt;javaee.version&gt;7.0&lt;/javaee.version&gt;
        &lt;springmvc.version&gt;4.3.6.RELEASE&lt;/springmvc.version&gt;
        &lt;/properties&gt;
  
        &lt;dependencies&gt;
  
        &lt;!--adding backend   --&gt;
        &lt;dependency&gt;
        &lt;groupId&gt;com.apurv&lt;/groupId&gt;
        &lt;artifactId&gt;shoppingbackend&lt;/artifactId&gt;
       &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;/dependency&gt;
  
        &lt;!-- https://mvnrepository.com/artifact/org.springframework/spring- 
          webmvc --&gt;
  
  
        &lt;!-- https://mvnrepository.com/artifact/javax/javaee-api --&gt;
         &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
          &lt;version&gt;${javaee.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
  
  
          &lt;dependency&gt;
            &lt;groupId&gt;junit&lt;/groupId&gt;
            &lt;artifactId&gt;junit&lt;/artifactId&gt;
            &lt;version&gt;3.8.1&lt;/version&gt;
            &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${springmvc.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/javax.servlet/jstl --&gt;
         &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
  
  
        &lt;/dependencies&gt;
        &lt;build&gt;
        &lt;plugins&gt;
        &lt;plugin&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;version&gt;3.1&lt;/version&gt;
        &lt;configuration&gt;
  
  
  
      &lt;source&gt;1.8&lt;/source&gt;
        &lt;target&gt;1.8&lt;/target&gt;
        &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;/plugins&gt;
          &lt;finalName&gt;onlineshopping&lt;/finalName&gt;
        &lt;/build&gt;
      &lt;/project&gt;
  
  pom.xml of the module which i have included in the above
  
  
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.apurv&lt;/groupId&gt;
    &lt;artifactId&gt;shoppingbackend&lt;/artifactId&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;shoppingbackend&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
    &lt;javaee.version&gt;7.0&lt;/javaee.version&gt;
    &lt;springmvc.version&gt;4.3.6.RELEASE&lt;/springmvc.version&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
    &lt;!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --&gt;
  
  
    &lt;!-- https://mvnrepository.com/artifact/javax/javaee-api --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax&lt;/groupId&gt;
      &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
      &lt;version&gt;${javaee.version}&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  
  
  
  
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
      &lt;version&gt;${springmvc.version}&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;!-- https://mvnrepository.com/artifact/javax.servlet/jstl --&gt;
     &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;jstl&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
  &lt;/dependency&gt;
  
  
    &lt;/dependencies&gt;
  
    &lt;build&gt;
    &lt;plugins&gt;
    &lt;plugin&gt;
    &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
    &lt;version&gt;3.1&lt;/version&gt;
    &lt;configuration&gt;
    &lt;source&gt;1.8&lt;/source&gt;
    &lt;target&gt;1.8&lt;/target&gt;
    &lt;/configuration&gt;
    &lt;/plugin&gt;
    &lt;/plugins&gt;
      &lt;finalName&gt;shoppingbackend&lt;/finalName&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>