Spring 3 MVC: Create Hello World application in Spring 3.0 MVC

Welcome to the Part 2 of Spring 3.0 MVC Series. In previous article we went through the Introduction of Spring MVC 3.0 framework, its request processing lifecycle and architecture diagram. In this article, let us create a simple Hello World application in Spring MVC 3.0.

For creating the hello world demo application, we will use Eclipse IDE.

Things We Need

Before we starts with our first Hello World Spring MVC Example, we will need few tools.

  1. JDK 1.5 above (download)
  2. Tomcat 5.x above or any other container (Glassfish, JBoss, Websphere, Weblogic etc) (download)
  3. Eclipse 3.2.x above (download)
  4. Spring 3.0 MVC JAR files:(download). Following are the list of JAR files required for this application.
    • commons-logging-1.0.4.jar
    • jstl-1.2.jar
    • org.springframework.asm-3.0.1.RELEASE-A.jar
    • org.springframework.beans-3.0.1.RELEASE-A.jar
    • org.springframework.context-3.0.1.RELEASE-A.jar
    • org.springframework.core-3.0.1.RELEASE-A.jar
    • org.springframework.expression-3.0.1.RELEASE-A.jar
    • org.springframework.web.servlet-3.0.1.RELEASE-A.jar
    • org.springframework.web-3.0.1.RELEASE-A.jar

Note that depending on the current version of Spring MVC, the version number of above jar files may change.

Our Goal

Our goal is to create a basic Spring MVC application using latest 3.0 version. There will be an index page which will display a link “Say Hello” to user. On clicking this link, user will be redirected to another page hello which will display a message “Hello World, Spring 3.0!”.
spring-mvc-hello-world-screen

Getting Started

Let us start with our first Spring 3.0 MVC based application.
Open Eclipse and goto File -> New -> Project and select Dynamic Web Project in the New Project wizard screen.
Dynamic Web Project in Eclipse

After selecting Dynamic Web Project, press Next.

eclipse-dynamic-web-project

Write the name of the project. For example Spring3MVC. Once this is done, select the target runtime environment (e.g. Apache Tomcat v6.0). This is to run the project inside Eclipse environment. After this press Finish.

Once the project is created, you can see its structure in Project Explorer.
spring-mvc-3-eclipse-project
Now copy all the required JAR files in WebContent > WEB-INF > lib folder. Create this folder if it does not exists.
spring-3-mvc-jar-files

The Spring Controller Class

We will need a spring mvc controller class that will process the request and display a “Hello World” message. For this we will create a package net.viralpatel.spring3.controller in the source folder. This package will contain the Controller file.
spring-3-package

Create a class called HelloWorldController in net.viralpatel.spring3.controller package and copy following content into it.

File: net.viralpatel.spring3.controller.HelloWorldController

package net.viralpatel.spring3.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloWorldController {

	@RequestMapping("/hello")
	public ModelAndView helloWorld() {

		String message = "Hello World, Spring 3.0!";
		return new ModelAndView("hello", "message", message);
	}
}

Note that we have annotated the HelloWorldController class with @Controller and @RequestMapping("/hello") on line 7 and 10. 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 /hello in the URL path. That includes /hello/* and /hello.html.

The helloWorld() method returns ModelAndView object. The ModelAndView object tries to resolve to a view named “hello” 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/hello.jsp". We will discuss this shortly how the logical name “hello” which is return in ModelAndView object is mapped to path /WEB-INF/jsp/hello.jsp.

The ModelAndView object also contains a message with key “message” and value “Hello World, Spring 3.0!”. 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.

The View: Create JSP

To display the hello world message we will create a JSP. Note that this JSP is created in folder /WEB-INF/jsp. Create hello.jsp under WEB-INF/jsp directory and copy following content into it.

File: WEB-INF/jsp/hello.jsp

<html>
<head>
	<title>Spring 3.0 MVC Series: Hello World - ViralPatel.net</title>
</head>
<body>
	${message}
</body>
</html>

The above JSP simply display a message using expression ${message}. Note that the name “message” is the one which we have set in ModelAndView object with the message string.

Also we will need an index.jsp file which will be the entry point of our application. Create a file index.jsp under WebContent folder in your project and copy following content into it.

File: WebContent/index.jsp

<html>
<head>
	<title>Spring 3.0 MVC Series: Index - ViralPatel.net</title>
</head>
<body>
	<a href="hello.html">Say Hello</a>
</body>
</html>

Mapping Spring MVC in WEB.xml

As discussed in the previous article (Introduction to Spring 3.0 MVC), the entry point of Spring MVC application will be the Servlet define in deployment descriptor (web.xml). Hence we will define an entry of org.springframework.web.servlet.DispatcherServlet class in web.xml.
Open web.xml file which is under WEB-INF folder and copy paste following code.

File: WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">
	<display-name>Spring3MVC</display-name>
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>

	<servlet>
		<servlet-name>spring</servlet-name>
		<servlet-class>
			org.springframework.web.servlet.DispatcherServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>spring</servlet-name>
		<url-pattern>*.html</url-pattern>
	</servlet-mapping>
</web-app>

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

One thing to note here is the name of servlet in <servlet-name> 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 spring-servlet.xml.

Spring configuration file

Create a file spring-servlet.xml in WEB-INF folder and copy following content into it.

File: WEB-INF/spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	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">

	<context:component-scan
		base-package="net.viralpatel.spring3.controller" />
		
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
		<property name="viewClass"
			value="org.springframework.web.servlet.view.JstlView" />
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>
</beans>

In the above xml configuration file, we have defined a tag <context:component-scan>. This will allow Spring to load all the components from package net.viralpatel.spring3.controller and all its child packages. This will load our HelloWorldController 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 HelloWorldController class, we have return a ModelAndView object with view name “hello”. This will be resolved to path /WEB-INF/jsp/hello.jsp.

That’s All Folks

You may want to run the application now and see the result. I assume you have already configured Tomcat in eclipse. All you need to do:
Open Server view from Windows > Show View > Server. Right click in this view and select New > Server and add your server details.
To run the project, right click on Project name from Project Explorer and select Run as > Run on Server (Shortcut: Alt+Shift+X, R)
spring-mvc-hello-world-screen

Download Source Code

Click here to download source code (9.05kb)

Moving On

In this tutorial we created a small Hello World application using Spring 3.0 MVC framework. Also we learned about the spring configuration and different annotations like @Controller and @RequestMapping. In next article we will see how easy it is to handle form data using Spring 3.0 MVC.



461 Comments

  • NITESH PAWAR 15 May, 2014, 11:21

    Hi Viral,

    Downloaded the project source code from this blog. It was observed that “hello” written in tag does not redirect to /WEB-INF/jsp/hello.jsp.

    Says that “The requested resource is not available”

    Below is the index.jsp file content –

    Spring 3.0 MVC Series: Index – Nitesh Pawar

    Say Hello

    Request you to provide a fix on this. Thank you.

    • NITESH PAWAR 15 May, 2014, 11:30

      it ihas worked now after seeing Fawad Khaliq comment.

  • Dlwk 10 June, 2014, 10:08

    Thats how I solved it :
    First, make sure the index.jsp is under WebContent/ (as I am using Websphere, it will be webapp/indes.jsp). Second, restart your server and application and make sure the tag in index.jsp is written like this:

     <a href="hello.html">Say Hello</a> 

    this is different from the source code which provided by author, but same as in the article, so i guess the author want us do in this way rather than following the provided source code(Its comes out 404 error too!!)

  • Anjali 11 July, 2014, 17:28

    Jul 11, 2014 5:12:04 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jre7\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\Program Files (x86)\RSA SecurID Token Common;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Lenovo\Access Connections\;C:\Program Files (x86)\IBM\Personal Communications\;C:\Program Files (x86)\IBM\Trace Facility\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\13.0\DLLShared\;C:\Program Files (x86)\IBM\Mobility Client\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;.
    Jul 11, 2014 5:12:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:Sample’ did not find a matching property.
    Jul 11, 2014 5:12:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:Spring3MVC’ did not find a matching property.
    Jul 11, 2014 5:12:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:SpringDemo’ did not find a matching property.
    Jul 11, 2014 5:12:04 PM org.apache.coyote.AbstractProtocolHandler init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    Jul 11, 2014 5:12:04 PM org.apache.coyote.AbstractProtocolHandler init
    INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
    Jul 11, 2014 5:12:04 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 894 ms
    Jul 11, 2014 5:12:04 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Jul 11, 2014 5:12:04 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
    Jul 11, 2014 5:12:06 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
    Jul 11, 2014 5:12:06 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
    Jul 11, 2014 5:12:06 PM org.apache.catalina.core.ApplicationContext log
    INFO: Marking servlet spring as unavailable
    Jul 11, 2014 5:12:06 PM org.apache.catalina.core.StandardContext loadOnStartup
    SEVERE: Servlet /Spring3MVC threw load() exception
    java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:289)
    at org.springframework.web.servlet.DispatcherServlet.(DispatcherServlet.java:213)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1062)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    Jul 11, 2014 5:12:06 PM org.apache.coyote.AbstractProtocolHandler start
    INFO: Starting ProtocolHandler ["http-bio-8080"]
    Jul 11, 2014 5:12:06 PM org.apache.coyote.AbstractProtocolHandler start
    INFO: Starting ProtocolHandler ["ajp-bio-8009"]
    Jul 11, 2014 5:12:06 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 1829 ms

  • Dexter 19 July, 2014, 13:15

    Getting following error: I have changed *.html to / in web.xml, but it is still not working

    Jul 19, 2014 1:13:20 PM org.springframework.web.servlet.PageNotFound noHandlerFound
    WARNING: No mapping found for HTTP request with URI [/Spring3MVC/hello] in DispatcherServlet with name ‘spring’

    Please someone help me out here

    • José 4 August, 2014, 7:20

      You need create a folder under WEB-INF called “jsp” and put there hello.jsp file

      +WEB-INF
      +—-jsp
      |——–hello.jsp

      Also change *.html for / in web.xml

  • haris 21 July, 2014, 9:14

    thanks for sample,
    in this sample in web.xml url pattern has to be as.

    /

  • Rehan 30 July, 2014, 8:22

    Hi Sir thanx for giving awesome tutorial. i just want to ask that how can i compile this web app into .EXE file and install on another pc and run without eclipse on other computer please replay me thanks in advance.

  • hejia 31 July, 2014, 15:50

    iam having error after copying the content into the class HelloWorldController

    • vedant 3 September, 2014, 14:12

      Add Spring MVC 3 libraries in configuration

  • Manohar 21 August, 2014, 15:50

    Hi patel

    this sample example i have been trying in jboss server it throws me the following exception
    can you pls help me on it but it works well in other servers like tomcat,weblogic etc..
    thanks !!
    Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) [org.springframework.web-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) [org.springframework.web-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) [org.springframework.context-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465) [org.springframework.context-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395) [org.springframework.context-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) [org.springframework.web.servlet-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) [org.springframework.web.servlet-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) [org.springframework.web.servlet-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) [org.springframework.web.servlet-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) [org.springframework.web.servlet-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
    at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1100) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3591) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3798) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [rt.jar:1.6.0_20]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_20]
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_20]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_20]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_20]
    at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_20]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
    Caused by: java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor

  • sakshi 28 August, 2014, 11:24

    i have tried the above program and i got the error while running the application using apache tomcat 6.
    Error:org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@112e7f7] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.

    Could you pls any body help me to solve this issue.

  • shaheed 15 October, 2014, 15:37

    i have tried the above program many times , i got the error while running the application using apache tomcat 7.0.
    type: Status report

    message

    description :The requested resource is not available.

  • rajendra 16 October, 2014, 15:50

    when i run above code in JBOSS 7.it gives below error. please give me solution for same
    and thnks in advance

    03:48:37,573 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) JBAS015003: Found SpringMVCFirst.war in deployment directory. To trigger deployment create a file called SpringMVCFirst.war.dodeploy
    03:48:37,590 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of “SpringMVCFirst.war”
    03:48:37,751 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit.”SpringMVCFirst.war”.POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit.”SpringMVCFirst.war”.POST_MODULE: Failed to process phase POST_MODULE of deployment “SpringMVCFirst.war”
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011093: Could not load component class org.springframework.web.servlet.DispatcherServlet
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:113)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:54)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
    … 5 more
    Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet from [Module "deployment.SpringMVCFirst.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:111)
    … 7 more

    03:48:37,777 INFO [org.jboss.as.server] (DeploymentScanner-threads – 2) JBAS015870: Deploy of deployment “SpringMVCFirst.war” was rolled back with failure message {“JBAS014671: Failed services” => {“jboss.deployment.unit.\”SpringMVCFirst.war\”.POST_MODULE” => “org.jboss.msc.service.StartException in service jboss.deployment.unit.\”SpringMVCFirst.war\”.POST_MODULE: Failed to process phase POST_MODULE of deployment \”SpringMVCFirst.war\””}}
    03:48:37,782 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015877: Stopped deployment SpringMVCFirst.war in 4ms
    03:48:37,785 INFO [org.jboss.as.controller] (DeploymentScanner-threads – 2) JBAS014774: Service status report
    JBAS014777: Services which failed to start: service jboss.deployment.unit.”SpringMVCFirst.war”.POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit.”SpringMVCFirst.war”.POST_MODULE: Failed to process phase POST_MODULE of deployment “SpringMVCFirst.war”

    03:48:37,789 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) {“JBAS014653: Composite operation failed and was rolled back. Steps that failed:” => {“Operation step-2″ => {“JBAS014671: Failed services” => {“jboss.deployment.unit.\”SpringMVCFirst.war\”.POST_MODULE” => “org.jboss.msc.service.StartException in service jboss.deployment.unit.\”SpringMVCFirst.war\”.POST_MODULE: Failed to process phase POST_MODULE of deployment \”SpringMVCFirst.war\””}}}}

Leave a Reply

Your email address will not be published. Required fields are marked *

Note

To post source code in comment, use [code language] [/code] tag, for example:

  • [code java] Java source code here [/code]
  • [code html] HTML here [/code]

Current ye@r *