<div dir="ltr" style="text-align: left;" trbidi="on">When we deploy a Spring MVC application into Tomcat and Servlet container not able to found this class <b>org.springframework.web.servlet.DispatcherServlet</b> then an Exception <b>java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet</b> error comes which usually found in the <b>spring-webmvc.jar</b> file.</p>
<div align='center' id="ads-id"></div>
<p>The DispatcherServlet is the core of Spring MVC framework, In Spring’s web MVC framework the mechanism of dispatching the request to the appropriate controllers is achieved by configuring the DispatcherServlet class. DispatcherServlet is the class which manages the entire request handling process.Like a normal servlet DispatcherServlet also needs to be configured in the web deployement Descriptor(web.xml) and specify the URL pattern such that Servlet container like Tomcat should send all HTTP request to DispatcherServlet. We also set load-on-startup tag as 1 for this Servlet, so that it should be loaded at deployment time. This Servlet is the link between Servlet Container and Spring MVC framework. </p>
<div style="background-color: #f2f9fc; border:1px solid #c9e6f2;border-radius:3px;padding:16px;line-height:1.45;"><b>Popular Tutorials</b></p>
<ul style="text-align: left;">
<li><b><a href="https://dineshonjava.com/2012/06/spring-30-baby-step-to-learn.html"><em><strong>Spring Tutorial</strong> </em></a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-web-mvc-framework-chapter-38.html"><strong><em>Spring MVC Web Tutorial </em></strong></a></b></li>
<li><b><a href="https://dineshonjava.com/2016/06/introduction-to-spring-boot-a-spring-boot-complete-guide.html"><em><strong>Spring Boot Tutorial</strong> </em></a></b></li>
<li><b><a href="https://dineshonjava.com/2013/02/spring-security-take-baby-step-to-secure.html"><em>Spring Security Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/2012/07/introduction-to-aop-in-spring.html"><em>Spring AOP Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/using-spring-jdbc-framework-chapter-32.html"><em>Spring JDBC Tutorial</em></a></b></li>
<li><b><a href="https://dineshonjava.com/2017/01/spring-hateoas-hypermedia-driven-restful-web-service.html"><em><strong>Spring HATEOAS </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/2017/01/microservices-with-spring-boot.html"><em><strong>Microservices with Spring Boot</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/2013/06/jax-rs-web-service-tutorial.html"><strong><em>REST Webservice</em> </strong></a></b></li>
<li><b><a href="https://dineshonjava.com/2013/01/core-java-baby-step-to-be-best-java-ian.html"><em><strong>Core Java </strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/2012/03/hibernate-3-on-baby-steps.html"><em><strong>Hibernate Tutorial</strong></em></a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-batch-process-with-example.html"><strong><em>Spring Batch</em> </strong></a></b></li>
</ul>
</div>
<p><b>DispatcherServlet in the deployment descriptor (web.xml)</b></p>
<pre class="highlight" name="code"><;?xml version="1.0" encoding="UTF-8"?>;
<;web-app 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">;
 <;servlet>;
 <;servlet-name>;dispatcher<;/servlet-name>;
 <;servlet-class>;org.springframework.web.servlet.DispatcherServlet<;/servlet-class>;
 <;load-on-startup>;2<;/load-on-startup>;
 <;/servlet>;
 <;servlet-mapping>;
 <;servlet-name>;dispatcher<;/servlet-name>;
 <;url-pattern>;*.html<;/url-pattern>;
 <;/servlet-mapping>;  ;
<;/web-app>;
</pre>
<p>
<b>Reason of java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet</b><br />
<b><br />
</b> When we deploy a Java web application which uses Spring MVC into a web server like Tomcat, it reads the deployment descriptor (web.xml file) and starts looking for org.springframework.web.servlet.DispatcherServlet in its classpath. As per Java EE specification, all application dependency JARs must be in WEB-INF/lib directory, so if doesn&#8217;t find the JAR there it will throw the java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet.</p>
<p><b>Error stacktrace of this issue like</b>:</p>
<p>java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet<br />
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)<br />
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)<br />
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)<br />
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)<br />
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)<br />
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)<br />
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)<br />
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)<br />
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)<br />
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)<br />
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)<br />
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)<br />
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)<br />
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:663)<br />
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1642)<br />
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)<br />
at java.util.concurrent.FutureTask.run(FutureTask.java:262)<br />
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br />
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br />
at java.lang.Thread.run(Thread.java:744)</p>
<p><b>Solution for java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet</b></p>
<p><b>Solution 1- </b>You did not include spring-beans and spring-context jars in your lib. If you are using maven (which will help a lot) those two lines will be enough</p>
<pre class="highlight" name="code"><;dependency>;
 <;groupId>;org.springframework<;/groupId>;
 <;artifactId>;spring-context<;/artifactId>;
 <;version>;4.1.0.RELEASE<;/version>;
<;/dependency>;
<;dependency>;
 <;groupId>;org.springframework<;/groupId>;
 <;artifactId>;spring-webmvc<;/artifactId>;
 <;version>;4.1.0.RELEASE<;/version>;
<;/dependency>;
</pre>
<p>
<b>Solution 2- </b>The necessary jars are in your classpath but are not deployed on tomcat.</p>
<ul style="text-align: left;">
<li>spring-beans &#8211; 4.1.0.RELEASE</li>
<li>spring-webmvc &#8211; 4.1.0.RELEASE</li>
<li>spring &#8211; 4.1.0.RELEASE</li>
</ul>
<div style="background-color: #f2f9fc; border:1px solid #c9e6f2;border-radius:3px;padding:16px;line-height:1.45;"><b>Spring MVC Related Posts</b></p>
<ol style="text-align: left;">
<li><b><a href="https://dineshonjava.com/2012/12/spring-web-mvc-framework-chapter-38.html">Spring MVC Web Tutorial</a></b></li>
<li><b><a href="https://dineshonjava.com/2017/02/spring-mvc-interview-questions-and-answers.html">Spring MVC Interview Questions</a></b></li>
<li><b><a href="https://dineshonjava.com/2013/07/introduction-to-mvc.html">MVC Design Pattern</a></b></li>
<li><b><a href="https://dineshonjava.com/2017/02/what-is-dispatcherservlet-in-spring-and-its-uses.html">Spring MVC DispatcherServlet </a></b></li>
<li><b><a href="https://dineshonjava.com/2017/02/difference-between-applicationcontext-webapplicationcontext-in-spring-mvc.html">Spring MVC WebApplicationContext and Root Application Context</a></b></li>
<li><b><a href="https://dineshonjava.com/2012/07/stereotype-annotations-in-spring.html">Spring MVC @Controller Annotation</a></b></li>
<li><b><a href="https://dineshonjava.com/2016/03/requestmapping-annotation-in-spring-mvc.html">Spring MVC @RequestMapping Annotation</a></b></li>
<li><b><a href="https://dineshonjava.com/2017/02/requestparam-annotation-in-spring-mvc-with-example.html">Spring MVC @RequestParam Annotation</a></b></li>
<li><b><a href="https://dineshonjava.com/2014/08/modelattribute-in-spring-mvc.html">Spring MVC @ModelAttribute Annotation</a></b></li>
<li><b><a href="https://dineshonjava.com/2017/02/difference-between-applicationcontext-webapplicationcontext-in-spring-mvc.html">Spring MVC ContextLoaderListener</a></b></li>
<li><b><a href="https://dineshonjava.com/2017/02/requestparam-vs-pathvariable-annotations-in-spring-mvc.html">Spring MVC @RequestParam and @PathVariable annotations</a></b></li>
<li><b><a href="https://dineshonjava.com/2017/02/spring-mvc-internalresourceviewresolver-configuration-example.html">Spring MVC InternalResourceViewResolver </a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-30-mvc-hello-world-example.html">Spring MVC Hello World Example</a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-exception-handling-example.html">Spring MVC Exception Handling Example</a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-mvc-with-hibernate-crud-example.html">Spring MVC with Hibernate CRUD Example</a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-3-mvc-tiles-plugin-with-example.html">Spring MVC Tiles Plugin with Example</a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-3-mvc-and-interceptor-with.html">Spring MVC Interceptor with example</a></b></li>
<li><b><a href="https://dineshonjava.com/2013/01/integration-spring-mvc3-and-mongodb.html">Spring MVC with MongoDB CRUD Example</a></b></li>
<li><b><a href="https://dineshonjava.com/2012/12/spring-3-mvc-internationalization.html">Spring MVC Internationalization &#038; Localization with Example</a></b></li>
</ol>
</div>
<p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/struts-to-spring-mvc-migration/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/exception-handling-in-spring-mvc/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '156'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…