title: HTTP Status 500 - Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
body: <p>Please don't flag this post as a duplicate one because I didn't find any good resource in the relevant question.</p>
  
  <p>Technologies used :- 
      Spring MVC 4.3.3.RELEASE
      Gradle 3.1
      Tomcat 9.0</p>
  
  <p>I created a dynamic web project and when I run it, I get the following error</p>
  
  <pre><code>HTTP Status 500 - Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
  
  type Exception report
  
  message Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  javax.servlet.ServletException: Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1102)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:788)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1485)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Thread.java:745)
  root cause
  
  java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
      org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1299)
      org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1133)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1102)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:788)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1485)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>It is saying that it could not find the dispatcher servlet class but when I <code>ctrl + click</code> the dispatcher servlet path in the <code>spring-dispatcher-servlet</code> , It lands to the spring Dispatcher Servlet class. I could not get the root cause of this problem.</p>
  
  <p>Here are my <code>web.xml</code> and <code>spring-dispatcher-servlet.xml</code> files</p>
  
  <p><code>web.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"&gt;
    &lt;display-name&gt;MenuOrder&lt;/display-name&gt;
  
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;spring-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;spring-dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  &lt;/web&gt;
  </code></pre>
  
  <p><code>spring-dispatcher-servlet.xml</code></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"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;
  
      &lt;bean id = "HandlerMapping" class = "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/&gt;
  
      &lt;bean id = "viewResolver" 
          class = "org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name = "prefix"&gt;
              &lt;value&gt;/WEB-INF/&lt;/value&gt;
          &lt;/property&gt;
  
          &lt;property name = "sufix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
          &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><code>Project directory</code></p>
  
  <p><a href="https://i.stack.imgur.com/DF7lJ.png" rel="nofollow"><img src="https://i.stack.imgur.com/DF7lJ.png" alt="enter image description here"></a></p>
  
  <p>My <code>gradle.build</code> file</p>
  
  <pre><code>allprojects{
  apply plugin: 'java'
  apply plugin: 'eclipse-wtp'
  group = 'com'
  version = '0.0.1-SNAPSHOT'
  }
  
  subprojects{
      tasks.withType(JavaCompile){
      options.encoding = 'UTF-8'
      }
  }
  
  
  
  allprojects {
      task hello { task -&gt; println "I'm $task.project.name" }
  }
  
  
  allprojects{
  
  repositories {
      mavenLocal()
      jcenter()
      mavenCentral()
  
  }
  
  
      dependencies {
  
          // The production code uses the SLF4J logging API at compile time
      //    compile 'org.slf4j:slf4j-api:1.7.21'
  
  
          //spring web
          compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.3.RELEASE'
  
          // spring core
          compile group: 'org.springframework', name: 'spring-core', version: '4.3.3.RELEASE'
  
          // spring context support
          compile group: 'org.springframework', name: 'spring-context-support', version: '4.3.3.RELEASE'
  
  
          // ORM dependencies
  
          // spring jpa
          compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.10.4.RELEASE'
  
          // hibernate-entity manager
          compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.2.2.Final'
  
          // End of ORM dependencies
  
          // postgres connector
          compile group: 'org.postgresql', name: 'postgresql', version: '9.4-1200-jdbc41'
  
          // Junit
          compile group: 'junit', name: 'junit', version: '4.12'
  
          // servlet
          compile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.0-b01'
  
          compile group: 'javax.el', name: 'javax.el-api', version: '2.2.1'
  
          compile group: 'org.springframework', name: 'spring', version: '3.2.0.RC1'
  
          }
          }
  </code></pre>
  
  <p>The whole project code can be found in 
  <a href="https://github.com/viper-pranish/menu-order" rel="nofollow">https://github.com/viper-pranish/menu-order</a> </p>
  
  <p>Dependencies inside the project structure</p>
  
  <p><a href="https://i.stack.imgur.com/5o8f9.png" rel="nofollow"><img src="https://i.stack.imgur.com/5o8f9.png" alt="enter image description here"></a></p>