Simplest Spring MVC Framework Tutorial – Hello World Example with UI (JSP) Page

Spring MVC tutorial - Crunchify Tutorial

Model-View-Controller (MVC) architecture provides the simplest way to develop flexible and loosely coupled web applications.

In this tutorial we will go over on how to create your 1st Spring MVC application with very detailed steps.

Do you have any of below questions?

Then you are at right place. Here I’ll demonstrate simple Spring MVC framework for building web applications.

First thing first – Let’s Setup Environment

Tutorial last updated and verified: February 2023 with below Tool versions.

I’m using below tools which you may need to download if you don’t have already.

Simplest Spring MVC tutorial by Crunchify.com

  1. Tomcat 9.0.38 – Download latest Apache Tomcat from this link.
  2. Make sure you download Eclipse IDE for Java EE Developers (2020‑09 R) – Download link. (diagram below)
  3. Spring 5.2.9.RELEASE (No download required) – we will use Maven dependency.
  4. JDK 15 – Download link.

Make sure you download latest Java EE Developer Kit:

Eclipse Photon IDE 4.8.0

Main goal for this tutorial to create Spring MVC Application in the simplest way.

Before we get started let’s see what we will see at the end of this tutorial 🙂

This is how our application result will look like. This is a final result once you complete all below steps.

Here is a final result: Welcome page ==> index.jsp

CrunchifySpringMVCTutorial index.jsp page

Result returns from Controller Class 🙂

Message Coming from Controller

Now Let’s get started on Tutorial

Step-1

Create New Eclipse Workspace - Crunchify Tips

Step-2

Create Crunchify Spring MVC Dynamic Web Project

Step-3

Convert Project to Maven Project to add all required Spring MVC dependencies to project.

Steps:

Convert Dynamic Web Project to Maven ProjectConvert CrunchifySpringMVCTutorial to Maven project

Step-4

Open pom.xml file and add below jar dependencies to project.

Crunchify Spring MVC pom.xml Dependencies

NOTE: Here is my pom.xml file. Make sure you update Java version to 13 if you haven’t yet moved to JDK 13 . We will keep updating this tutorial to latest Spring MVC version.

So below pom.xml file may have different (latest) version of Spring MVC dependencies than above image 🙂

 4.0.0 CrunchifySpringMVCTutorial CrunchifySpringMVCTutorial 0.0.1-SNAPSHOT war src  maven-compiler-plugin 3.8.0 13   maven-war-plugin 3.2.1 WebContent      org.springframework spring-core 5.2.3.RELEASE  org.springframework spring-context 5.2.3.RELEASE  org.springframework spring-aop 5.2.3.RELEASE  org.springframework spring-webmvc 5.2.3.RELEASE  org.springframework spring-web 5.2.3.RELEASE  javax.servlet jstl 1.2   

Step-5

Create new Spring Configuration Bean file: /WebContent/WEB-INF/crunchify-servlet.xml

Create crunchify-servlet.xml file - Spring MVC project

crunchify-servlet.xml

In the above crunchify-servlet.xml configuration file, we have defined a tag . This will allow Spring to load all the components from package com.crunchify.controller and all its child packages.

This will load our CrunchifyHelloWorld.class . Also we have defined a bean viewResolver . This bean will resolve the view and add prefix string /WEB-INF/jsp/ and suffix .jsp to the view in ModelAndView.

Note that in our CrunchifyHelloWorld class, we have return a ModelAndView object with view name welcome.

This will be resolved to path /WEB-INF/jsp/welcome.jsp .

Step-6

Create new file web.xml if it’s already not there. Map Spring MVC in /WebContent/WEB-INF/web.xml file.

NOTE: if you don’t see web.xml file in your “ dynamic web project ” then follow these steps.

web.xml

  CrunchifySpringMVCTutorial index.html index.htm index.jsp default.html default.htm default.jsp  crunchify org.springframework.web.servlet.DispatcherServlet 1  crunchify /welcome.jsp /index.jsp /welcome.html *.html  

The above code in web.xml will map DispatcherServlet with url pattern /welcome.jsp . Also note that we have define index.jsp as welcome file.

One thing to note here is the name of servlet in tag in web.xml . Once the DispatcherServlet is initialized, it will looks for a file name [servlet-name]-servlet.xml in WEB-INF folder of web application. In this example, the framework will look for file called crunchify-servlet.xml .

Step-7

Create Controller Class.

Create Spring Controller Class CrunchifyHelloWorld

CrunchifyHelloWorld.java

package com.crunchify.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; /* * author: Crunchify.com * */ @Controller public class CrunchifyHelloWorld < @RequestMapping("/welcome") public ModelAndView helloWorld() < String message = "
" + "

********** Hello World, Spring MVC Tutorial

This message is coming from CrunchifyHelloWorld.java **********


"; return new ModelAndView("welcome", "message", message); > >

Note that we have annotated the CrunchifyHelloWorld class with @Controller and @RequestMapping("/welcome") . When Spring scans our package, it will recognize this bean as being a Controller bean for processing requests. The @RequestMapping annotation tells Spring that this Controller should process all requests beginning with /welcome in the URL path. That includes /welcome/* and /welcome.html .

The helloWorld() method returns ModelAndView object. The ModelAndView object tries to resolve to a view named “welcome” and the data model is being passed back to the browser so we can access the data within the JSP. The logical view name will resolve to /WEB-INF/jsp/welcome.jsp . Logical name “welcome” which is return in ModelAndView object is mapped to path /WEB-INF/jsp/welcome.jsp.

The ModelAndView object also contains a message with key “message” and Detailed value. This is the data that we are passing to our view. Normally this will be a value object in form of java bean that will contain the data to be displayed on our view. Here we are simply passing a string.

Step-8

The View – Create new file /WebContent/index.jsp .

index.jsp

  Spring MVC Tutorial Series by Crunchify.com    
Hey You. This is your 1st Spring MCV Tutorial..

Click here to See Welcome Message. (to check Spring MVC Controller. @RequestMapping("/welcome"))

Create another file /WebContent/WEB-INF/jsp/welcome.jsp .

NOTE: Don’t forget to create jsp folder and put welcome.jsp inside that 🙂

welcome.jsp

  Spring MVC Tutorial by Crunchify - Hello World Spring MVC Example   $  

Spring MCV Tutorial by Crunchify. Click here for all Java and here for all Spring MVC, Web Development examples.

After everything this is how your workspace should look like.

Simplest Spring MVC Tutorial Project Structure - Crunchify

Step-9

Right Click on Project -> Run As -> Maven Build.

Maven Run-as - Maven Build in Eclipse IDE

Add Goals : clean install . Click Apply and Run .

Clean Install maven Spring project

You should see build success message :

Spring MVC Maven Clean Install Build Success Message

Where are all of my .jar files?

You will see all .jar files under /target folder. Screenshot.

Step-10

Start Apache Tomcat in Eclipse - Crunchify Tips

Make sure you see below logs. That means your application is successfully deployed on Tomcat Web Server.

Aug 04, 2018 9:08:10 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule] Setting property 'source' to 'org.eclipse.jst.jee.server:CrunchifySpringMVCTutorial' did not find a matching property. INFO: Server version: Apache Tomcat/9.0.10 INFO: Server built: Jun 20 2018 17:32:21 UTC INFO: Server number: 9.0.10.0 INFO: OS Name: Mac OS X INFO: OS Version: 10.13.6 INFO: Architecture: x86_64 INFO: Java Home: /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home INFO: JVM Version: 10.0.2+13 INFO: JVM Vendor: "Oracle Corporation" INFO: CATALINA_BASE: /Users/appshah/Documents/jee-photon/workspace/c/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 INFO: CATALINA_HOME: /Users/appshah/Documents/jee-photon/apache-tomcat-9.0.10 INFO: Command line argument: -Dcatalina.base=/Users/appshah/Documents/jee-photon/workspace/c/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 INFO: Command line argument: -Dcatalina.home=/Users/appshah/Documents/jee-photon/apache-tomcat-9.0.10 INFO: Command line argument: -Dwtp.deploy=/Users/appshah/Documents/jee-photon/workspace/c/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps INFO: Command line argument: -Dfile.encoding=UTF-8 INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/appshah/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.] INFO: Initializing ProtocolHandler ["http-nio-8080"] INFO: Using a shared selector for servlet write/read INFO: Initializing ProtocolHandler ["ajp-nio-8009"] INFO: Using a shared selector for servlet write/read INFO: Initialization processed in 841 ms INFO: Starting service [Catalina] INFO: Starting Servlet Engine: Apache Tomcat/9.0.10 INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. INFO: No Spring WebApplicationInitializer types detected on classpath INFO: Initializing Spring FrameworkServlet 'crunchify' INFO: FrameworkServlet 'crunchify': initialization started INFO: Refreshing WebApplicationContext for namespace 'crunchify-servlet': startup date [Sat Aug 04 21:08:13 CDT 2018]; root of context hierarchy INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/crunchify-servlet.xml] INFO: Mapped "<[/welcome]>" onto public org.springframework.web.servlet.ModelAndView com.crunchify.controller.CrunchifyHelloWorld.helloWorld() INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace 'crunchify-servlet': startup date [Sat Aug 04 21:08:13 CDT 2018]; root of context hierarchy INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace 'crunchify-servlet': startup date [Sat Aug 04 21:08:13 CDT 2018]; root of context hierarchy INFO: Mapped URL path [/**] onto handler 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0' INFO: FrameworkServlet 'crunchify': initialization completed in 1607 ms INFO: Starting ProtocolHandler ["http-nio-8080"] INFO: Starting ProtocolHandler ["ajp-nio-8009"] INFO: Server startup in 3579 ms

Step-11. Done.

Hurray.. Now you know Hello World Spring MVC 5 Example . Let me know if you encounter any exception while running this. There are lot more example you can find here.

Do you want to include JS, CSS and images into JSP file? Follow this tutorial: Best way to Add/Integrate JS, CSS and images into JSP file using ‘mvc:resources mapping’.

Having trouble? Any issue?

Triaging Step-1 – Having HTTP Status 404 error?

Make sure welcome.jsp file is inside jsp folder


Also, follow below tutorial:

Spring MVC tutorial - Eclipse Target Runtime Setting

Triaging Step-3 – maven errors?

Make sure to update all maven dependencies.

Force Update dependencies - Spring MVC tutorial

Feel free to email or comment below if you have any problem running above tutorial.

If you liked this article, then please share it on social media. Have a question or suggestion? Please leave a comment to start the discussion.

Suggested Articles.

  1. How to create 1st Web based Spring Boot HelloWorld App in IntelliJ IDEA with few simple steps?
  2. Build RESTful Service in Java using JAX-RS and Jersey (Celsius to Fahrenheit & Fahrenheit to Celsius)
  3. Java Spring Boot Tutorial – Live Hello-World Web Application Example with Detailed Steps
  4. What is pom.xml (Project Object Model)? Sample pom.xml for you to use in your Dynamic Web Project (Java / J2EE)
  5. How to Install and Configure Elasticsearch on your Dev/Production environment?
  6. Servlet Tutorial: Getting Starting with JSP – Servlet Example

Give me a try.

About App

I'm an Engineer by profession, Blogger by passion & Founder of Crunchify, LLC, the largest free blogging & technical resource site for beginners. Love SEO, SaaS, #webperf, WordPress, Java. With over 16 millions+ pageviews/month, Crunchify has changed the life of over thousands of individual around the globe teaching Java & Web Tech for FREE.

Reader Interactions

439 Comments.

  1. yuki says Jun 28, 2024 at 12:15 am

I got an error that the DispatcherServlet was not found, so I added it during deployment/implementation based on the video, but the item JavaBuildPathEntries does not exist. All that is there is the folder and project.

This tutorial simplifies Spring MVC with its concise “Hello World” example. The step-by-step guidance, coupled with practical tips, makes it an excellent resource for beginners. Whether you’re new to Spring or seeking a refresher, this article offers an easy entry point into the world of Spring Model-View-Controller.

When I tried the tutorial as written. It would just show the index.jsp source code and not actually compile the index.jsp file. Once I removed the /index.jsp line in the block of the web.xml then it all worked as expected. I am not sure why but if others are seeing this issue then it may be a fix for them as well.

Hi SDavis. Thanks for reaching out. I’ll check this out in few days and will update. Thanks,
App Shah

You are a freaking lifesaver! I have been following multiple tutorials (some free – some paid) for weeks, and Spring MVC would NOT HAPPEN. Everything seems out of date. Yours is the first that worked! I am going to take what you did and apply it to my stinking course I paid for to see if I can actually finish it. Note for others: I did have to do the second, included tutorial about adding the Maven dependencies, and the link from the final screenshot is the one that worked: http://localhost:8080/CrunchifySpringMVCTutorial/welcome.html

Yeah Audra. That’s right. This tutorial saved me so many days. I was playing Spring MVC for long time and finally this tutorial worked.

I am planned to migrate existing SpringMVC 3 code running on Websphere Application to SpringMVC 5 with Tomcat as webserver, is this template can be used for the development?

Hi Sri. I just tried that and it worked perfectly fine for me. Same template can be used for the Spring MVC 5 with Tomcat.

Very well done tutorial. Thanks! Worked like a charm.

I keep hitting this error (refer to below). Uses JDK 14, and compile it with JDK 14.
I try lower it to JDK 13 and I still hit the same error message. “this version of the Java Runtime only recognizes class file versions up to 52.0” https://uploads.disquscdn.com/images/a6e07a1544281ee3f120a64cb9085bf10eae996742cc44c30f76b712a80139d2.png

Hi there – this seems like JDK and JRE conflict. Once suggestion would be to uninstall JDK 13 completely and try with only JDK 14. Just incase if helps, try restarting your work station. https://media1.giphy.com/media/l0Ex0do3cmuvvcCSA/giphy.gif

Fantastic Stuff Sir. That’s right. Worked for me. Thank you App for great tutorial.

Interesting Allan. Are you loading page on which browser? Seems like content-type text/html Vs. text/plain issue. Can you try loading http://localhost:8080/SpringMVC/index.jsp ?

Hi sir, I’m not getting
BUILD SUCCESS. [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [INFO] 1 error This is my error. I'm using JAVASE-1.8 and my maven-compiler-plugin version is 3.7.0 and maven-war-plugin version is 3.2.1.
Please help me.

Hi Vishnu. Please make sure to provide full path of your installed JDK in Eclipse. Once done, try running it again. Hope this helps!

The program worked . Got the output sir. Thank you very much. I have another program that shoes XmlBeanDefinitionStoreException , Please let me know how to solve this problem.

You are welcome Vishnu. Seems like an issue with xml namespace definition. Could you please share complete stack trace?

I found the problem sir. But there is another issue now. When I visited the URL : http://localhost:8080/CrunchifySpringMVCTutorial/ ,it says Site Can’t be reached. But if I run in eclipse it’s is working. Please help. Thank You.

I’m glad you found an issue and saw your update that you fixed it 🙂

Followed the steps to this and it didn’t work. I keep getting this error and don’t have a clue what it means. https://uploads.disquscdn.com/images/472246f5029d2025d76be8d50213c7ed370f9af6b9b728bcd677177e426f6c73.png

Hi Michael – this seems like an issue with dependency. Can you please try doing maven clean install and try again?

INFO: Starting service [Catalina] Aug 14, 2019 11:57:29 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet engine: [Apache Tomcat/9.0.22] Aug 14, 2019 11:57:29 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [268] milliseconds. Aug 14, 2019 11:57:32 AM org.apache.catalina.core.ContainerBase startInternal SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/FirstApp]] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/FirstApp]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) . 21 more Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering. at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2257) at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2215) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1134) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:775) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) . 27 more Aug 14, 2019 11:57:32 AM org.apache.catalina.core.ContainerBase startInternal SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) . 13 more Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/FirstApp]] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) . 21 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/FirstApp]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) . 21 more Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering. at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2257) at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2215) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1134) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:775) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) . 27 more Aug 14, 2019 11:57:32 AM org.apache.catalina.startup.Catalina start SEVERE: The required Server component failed to start so Tomcat is unable to start. org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) . 13 more Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) . 13 more Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/FirstApp]] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) . 21 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/FirstApp]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) . 21 more Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering. at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2257) at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2215) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1134) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:775) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) . 27 more Aug 14, 2019 11:57:32 AM org.apache.coyote.AbstractProtocol pause INFO: Pausing ProtocolHandler ["http-nio-8080"] Aug 14, 2019 11:57:32 AM org.apache.coyote.AbstractProtocol pause INFO: Pausing ProtocolHandler ["ajp-nio-8009"] Aug 14, 2019 11:57:32 AM org.apache.catalina.core.StandardService stopInternal INFO: Stopping service [Catalina] Aug 14, 2019 11:57:32 AM org.apache.coyote.AbstractProtocol destroy INFO: Destroying ProtocolHandler ["http-nio-8080"] Aug 14, 2019 11:57:32 AM org.apache.coyote.AbstractProtocol destroy INFO: Destroying ProtocolHandler ["ajp-nio-8009"] WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%209.0/lib/catalina.jar) to field java.io.ObjectStreamClass$Caches.localDescs WARNING: Please consider reporting this to the maintainers of org.apache.catalina.loader.WebappClassLoaderBase WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

Hi Hyder – Above error comes, when you have two different versions of Spring Dependencies. Could you please check your dependencies to see if you have a dependency to another Spring-version. Run below command in your terminal at Maven project root to locate conflicting dependencies. mvn dependency:tree -Dverbose -Dincludes=groupId:artifactId Also, please add tag to your web.xml just under the tag. Hope this helps.

Hello everyone, please help me with 404 error. I have performed all the steps as given in this post. What is problem?
https://uploads.disquscdn.com/images/cb7973f699fd8586454646a89f3e186dd06bd948635a543bfa7091849eb42ad5.png

Hi Анастасия Кравцова – can you please share console log? I’ll be able to help you find root cause. Also, as I usually suggest try cleaning project one more time. maven clean install.

XML config should be a crime these days! What is that 🙂 Not everybody moved over to JSON and latest stuff.. Wish other guides were as clear as this – thanks! Thanks Jack for kind words. I’m glad tutorial works well for you. Appreciate your comment.

hi I have the 404 issue with unavailable resource.
I have watched the video but it’s designed for eclipse, could you tell me I should do in intellij?
thank you

Hi Elodie – i recently started playing with Intellij. I’ll try to run Spring MVC on Intellij in free time. Will keep you posted. Happy coding!

Is it just me, or is this very complicated compared to node.js? This is 6 lines of code with expressjs. Am I missing something?

Hi there – do you have your code handy which you want to share with Crunchify readers? I would love to look at Express JS. Thanks for sharing tips.

Wow, this tutorial was amazing. I struggled with eclipse, maven, spring, spring boot, and spring mvc while trying to set up a web app for 2 days straight, but following this got it to work on the first try. Bravo!!

Very happy to help Kronn8. I’m glad it worked at the first attempt without any issue. At Crunchify, our goal is to provide very simple tutorial for all of our readers 🙂 Happy coding.

I am not able to add Jar dependencies of spring-core, what is the problem ? What problem are you facing? Can you share screenshot? Is it pom error or build error?

I also need one more line above to make it navigated to welcome page. So, the solution to make it work is: .

Thanks Helen – Just updated tutorial with fix and with all latest maven dependencies.

I got “No mapping found for HTTP request with URI in DispatcherServlet.
I searched for an answer. In crunchify-servlet, add a line below : . Now, it works.

Hi Helen. Thanks for sharing tips. We have already added tips to our tutorial.

With Spring 4.3.16, it doesn’t support creating and returning a new ModelAndView inside RequestMapping method. Instead you need to use a method signature like following:

@RequestMapping("/welcome") public String helloWorld(Model model)

Hi Steve Wang – I’ve just updated tutorial with all latest versions and fixed few bugs. Tutorial should work out of the box now. Could you try and let me know for any issue if you face?

my first spring tutorial worked without frustration. Super cool. Thanks for taking a time to provide feedback. generate-resource step missing

Hi JO – what do you mean missing generate-resource step? Are you referring to step-9 (Building project) step?

I tried your tutorial, but my server won’t start. Heres the stack trace:
Mai 07, 2018 5:30:53 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNUNG: [SetPropertiesRule] Setting property 'source' to 'org.eclipse.jst.jee.server:CrunchifySpringMVCTutorial' did not find a matching property. Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Server version: Apache Tomcat/8.0.48 Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Server built: Nov 30 2017 16:26:50 UTC Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Server number: 8.0.48.0 Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: OS Name: Linux Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: OS Version: 4.13.0-39-generic Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Architecture: amd64 Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Java Home: /usr/lib/jvm/java-8-oracle/jre Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: JVM Version: 1.8.0_171-b11 Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: JVM Vendor: Oracle Corporation Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: CATALINA_BASE: /home/beer/workspace/spring/mvc/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: CATALINA_HOME: /opt/tomcat Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Command line argument: -Dcatalina.base=/home/beer/workspace/spring/mvc/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Command line argument: -Dcatalina.home=/opt/tomcat Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Command line argument: -Dwtp.deploy=/home/beer/workspace/spring/mvc/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Command line argument: -Djava.endorsed.dirs=/opt/tomcat/endorsed Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.VersionLoggerListener log INFORMATION: Command line argument: -Dfile.encoding=UTF-8 Mai 07, 2018 5:30:53 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFORMATION: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib Mai 07, 2018 5:30:53 PM org.apache.coyote.AbstractProtocol init INFORMATION: Initializing ProtocolHandler ["http-nio-8080"] Mai 07, 2018 5:30:53 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFORMATION: Using a shared selector for servlet write/read Mai 07, 2018 5:30:53 PM org.apache.coyote.AbstractProtocol init INFORMATION: Initializing ProtocolHandler ["ajp-nio-8009"] Mai 07, 2018 5:30:53 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFORMATION: Using a shared selector for servlet write/read Mai 07, 2018 5:30:53 PM org.apache.catalina.startup.Catalina load INFORMATION: Initialization processed in 1450 ms Mai 07, 2018 5:30:53 PM org.apache.catalina.core.StandardService startInternal INFORMATION: Starting service Catalina Mai 07, 2018 5:30:53 PM org.apache.catalina.core.StandardEngine startInternal INFORMATION: Starting Servlet Engine: Apache Tomcat/8.0.48 Mai 07, 2018 5:31:00 PM org.apache.catalina.core.ApplicationContext log INFORMATION: No Spring WebApplicationInitializer types detected on classpath Mai 07, 2018 5:31:00 PM org.apache.jasper.servlet.TldScanner scanJars INFORMATION: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Mai 07, 2018 5:31:00 PM org.apache.catalina.core.ContainerBase startInternal SCHWERWIEGEND: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/CrunchifySpringMVCTutorial]] at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/CrunchifySpringMVCTutorial]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) . 6 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@773a8781] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4968) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5101) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) . 6 more Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@77d37319] at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:135) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:722) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) . 9 more Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:142) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102) . 12 more Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) at java.util.zip.ZipFile.access$1400(ZipFile.java:60) at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:734) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) at sun.misc.IOUtils.readFully(IOUtils.java:65) at java.util.jar.JarFile.getBytes(JarFile.java:425) at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193) at java.util.jar.JarFile.getManifest(JarFile.java:180) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:140) . 13 more Mai 07, 2018 5:31:00 PM org.apache.catalina.core.ContainerBase startInternal SCHWERWIEGEND: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]] at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:789) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.startup.Catalina.start(Catalina.java:630) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:349) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:483) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:951) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) . 6 more Mai 07, 2018 5:31:00 PM org.apache.catalina.startup.Catalina start SCHWERWIEGEND: The required Server component failed to start so Tomcat is unable to start. org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.startup.Catalina.start(Catalina.java:630) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:349) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:483) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:789) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) . 7 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) . 9 more Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:951) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) . 11 more Mai 07, 2018 5:31:00 PM org.apache.coyote.AbstractProtocol pause INFORMATION: Pausing ProtocolHandler ["http-nio-8080"] Mai 07, 2018 5:31:00 PM org.apache.coyote.AbstractProtocol pause INFORMATION: Pausing ProtocolHandler ["ajp-nio-8009"] Mai 07, 2018 5:31:00 PM org.apache.catalina.core.StandardService stopInternal INFORMATION: Stopping service Catalina Mai 07, 2018 5:31:00 PM org.apache.coyote.AbstractProtocol destroy INFORMATION: Destroying ProtocolHandler ["http-nio-8080"] Mai 07, 2018 5:31:00 PM org.apache.coyote.AbstractProtocol destroy SCHWERWIEGEND: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"] java.lang.NullPointerException at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:315) at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:491) at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:896) at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:551) at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:879) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.startup.Catalina.start(Catalina.java:634) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:349) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:483) Mai 07, 2018 5:31:00 PM org.apache.coyote.AbstractProtocol destroy INFORMATION: Destroying ProtocolHandler ["ajp-nio-8009"] Mai 07, 2018 5:31:00 PM org.apache.coyote.AbstractProtocol destroy SCHWERWIEGEND: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"] java.lang.NullPointerException at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:315) at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:491) at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:896) at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:551) at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:879) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.startup.Catalina.start(Catalina.java:634) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:349) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:483)
Hi There – seems like an issue with your application.
java.lang.NullPointerException at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:315) at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:491) at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:896)
Please email me your code via email and i’ll take a look.

Hi AppShah, I have performed all the steps as given in your post, still I am getting a 404 error while accessing the welcome file.
Also I am not getting any error or exception on my console as well. https://uploads.disquscdn.com/images/c800ad54970a83c0b1bf778d6fe64743fd43b61e3be55c6fc2e3638e690b8249.png

Hi Marodarken – could you also try follwoing tutorial again. I found a bug and fixed today.

Hi Saurabh – I’ve just updated tutorial with all latest maven dependencies and fixed above 404 error. Could you please try again with updated crunchify-servlet.xml file? Finger crossed 🙂

I tried all solutions and still het no welcome.html – PLEASE HELP HTTP Status 404 – /PractizerWeb/welcome.html
type Status report
message /PractizerWeb/welcome.html
description The requested resource is not available.

Hi Dali – can you please share screenshot of the error? Also, share exception stacktrace from your eclipse console.

Hi Folks, All who are facing issues , just make sure about three important things. 1 ) Name of the servlet xml file. i.e. It should match with the name mentioned in web.xml for the servlet. 2) in servlet mapping provide the / in url-pattern and forget about the other .jsp & html mappings. 3) Make sure your index.jsp is inside the WebContent folder and NOT INSIDE THE WEB-INF. I”m sure if you guys are following these three notes proper then you will not face any issues while running this program. Also if anybody is facing issues in maven clean or build, make sure about the JDK path at the Window->Preferences-> Installed JREs I would like to thank author for the simple Hello World tutorial using Spring MVC. Thanks,
Kailash

You are welcome Kailash. Thanks for summarizing steps which will definitely help all other Java coders out there.

I followed the tutorial step by step. But I got the following error. How can I fix it?
http://localhost:8080/CrunchifySpringMVCTutorial/

Hi there – could you please share exception stack trace to debug further. Make sure to clean your project in Eclipse.

I have tried to create the project many times .Also by simple maven project also.But it fails with below message each time.Server also starts correctly each time.
“The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.”

Hi Neer – did you get chance to clean your project? Maven clean install is the best option 🙂 It shows me : HTTP Status 404 – description: The requested resource is not available.

Hi DanG – do you have detailed stack trace? Can you share with me and i’ll take a look at that in details. Thanks.

Same with you on it. Always 404, until remove this line ‘/index.jsp’ in web.xml. It means that map request default ‘index.jsp’ to servlet, but we set index.jsp in WebContent folder and it doesn’t need this mapping.
Eclipse Oxygen jee 4.7.2/Maven 3.7/spring 5.0.3

Brilliant!
Exactly the same problem solved by removing /index.jsp in web.cml.7
Thanks! Beside that good tutorial.

I must appreciate very detailed explanation.I tried this code.
But i wonder why the versions of jars are different from those which are expected to be added in the class path?May be because of this I am getting class path isssue.
Please refer snapshot of step 4 which has version 4.3.1 against the one you mentioned under the pom which is 4.3.7.RELEASE .

Hi Daksh – good observation. Please note though: I keep updating pom.xml file with latest Spring MVC jar files. It’s always good idea to update project with latest version 🙂 So, if you see mismatch in Spring version then don’t worry. After updating jar version – simply clean your project and you should be good. Hope that helps.

exact same error, fix is to modify /CrunchifySpringMVCTutorial/WebContent/WEB-INF/crunchify-servlet.xml adding a line . Result: …

Which lines to add?
 crunchify /welcome.jsp /index.jsp /welcome.html *.html