java - HTTP 404 error code in spring MVC web app for hello world app -


i trying implement simple spring mvc web app.i build project in eclipse , during deployment on tomcat getting error.

error code: enter image description here

folder structure enter image description here web.xml

<?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">    <display-name>theka desi khana</display-name>   <!-- definition of root spring container shared servlets , filters -->     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>/web-inf/spring/root-context.xml</param-value>     </context-param>      <!-- creates spring container shared servlets , filters -->     <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>      <!-- processes application requests -->     <servlet>         <servlet-name>appservlet</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>         <init-param>             <param-name>contextconfiglocation</param-name>             <param-value>/web-inf/spring/appservlet/servlet-context.xml</param-value>         </init-param>         <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>appservlet</servlet-name>         <url-pattern>/</url-pattern>     </servlet-mapping>     <welcome-file-list>      <welcome-file>index.jsp</welcome-file>   </welcome-file-list> </web-app> 

root-context.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"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">   </beans> 

servlet-context.xml

<?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:mvc="http://www.springframework.org/schema/mvc"     xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">      <!-- dispatcherservlet context: defines servlet's request-processing          infrastructure -->      <context:component-scan base-package="com.theka.desi.controllers" />        <!-- resolves views selected rendering @controllers .jsp resources in /web-inf/views directory -->       <beans:bean class="org.springframework.web.servlet.view.internalresourceviewresolver">         <beans:property name="prefix" value="/web-inf/views/" />         <beans:property name="suffix" value=".jsp" />     </beans:bean>        <!-- handles http requests /resources/** efficiently serving          static resources in ${webapproot}/resources directory -->     <resources mapping="/resources/**" location="/resources/" />         </beans:beans> 

homecontroller

   package com.theka.desi.controllers;   import javax.servlet.servletcontext;  import org.apache.log4j.logger; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.servlet.modelandview; @controller @requestmapping("/") public class homecontroller {     @autowired     private servletcontext servletcontext;     private final logger logger = logger.getlogger(homecontroller.class);      public servletcontext getservletcontext() {         return servletcontext;     }      public void setservletcontext(servletcontext servletcontext) {         this.servletcontext = servletcontext;     }        @requestmapping("/")         public string welcome() {             return "redirect:/home";         }          @requestmapping("/home")         public modelandview home() {             modelandview view = new modelandview("index");              return view;         }       } 

console log:

   mar 26, 2016 6:09:56 pm org.apache.tomcat.util.digester.setpropertiesrule begin warning: [setpropertiesrule]{server/service/engine/host/context} setting property 'source' 'org.eclipse.jst.j2ee.server:desi' did not find matching property. mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: server version:        apache tomcat/7.0.65 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: server built:          oct 9 2015 08:36:58 utc mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: server number:         7.0.65.0 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: os name:               windows 8.1 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: os version:            6.3 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: architecture:          amd64 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: java home:             c:\program files\java\jdk1.7.0_79\jre mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: jvm version:           1.7.0_79-b15 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: jvm vendor:            oracle corporation mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: catalina_base:         c:\users\nand\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: catalina_home:         g:\softy\apache-tomcat-7.0.65-windows-x64\apache-tomcat-7.0.65 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dcatalina.base=c:\users\nand\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dcatalina.home=g:\softy\apache-tomcat-7.0.65-windows-x64\apache-tomcat-7.0.65 mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dwtp.deploy=c:\users\nand\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -djava.endorsed.dirs=g:\softy\apache-tomcat-7.0.65-windows-x64\apache-tomcat-7.0.65\endorsed mar 26, 2016 6:09:56 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dfile.encoding=cp1252 mar 26, 2016 6:09:56 pm org.apache.catalina.core.aprlifecyclelistener lifecycleevent info: apr based apache tomcat native library allows optimal performance in production environments not found on java.library.path: c:\program files\java\jdk1.7.0_79\bin;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\program files (x86)\git\cmd;c:\program files (x86)\git\bin;c:\program files (x86)\common files\lenovo\easyplussdk\bin;c:\program files (x86)\skype\phone\;. mar 26, 2016 6:09:56 pm org.apache.coyote.abstractprotocol init info: initializing protocolhandler ["http-bio-8080"] mar 26, 2016 6:09:56 pm org.apache.coyote.abstractprotocol init info: initializing protocolhandler ["ajp-bio-8009"] mar 26, 2016 6:09:56 pm org.apache.catalina.startup.catalina load info: initialization processed in 1234 ms mar 26, 2016 6:09:56 pm org.apache.catalina.core.standardservice startinternal info: starting service catalina mar 26, 2016 6:09:56 pm org.apache.catalina.core.standardengine startinternal info: starting servlet engine: apache tomcat/7.0.65 mar 26, 2016 6:09:59 pm org.apache.catalina.startup.tldconfig execute info: @ least 1 jar scanned tlds yet contained no tlds. enable debug logging logger complete list of jars scanned no tlds found in them. skipping unneeded jars during scanning can improve startup time , jsp compilation time. mar 26, 2016 6:09:59 pm org.apache.catalina.core.applicationcontext log info: no spring webapplicationinitializer types detected on classpath mar 26, 2016 6:09:59 pm org.apache.catalina.core.applicationcontext log info: initializing spring root webapplicationcontext log4j:warn no appenders found logger (org.springframework.web.context.contextloader). log4j:warn please initialize log4j system properly. mar 26, 2016 6:09:59 pm org.apache.catalina.core.applicationcontext log info: initializing spring frameworkservlet 'appservlet' mar 26, 2016 6:10:00 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["http-bio-8080"] mar 26, 2016 6:10:00 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["ajp-bio-8009"] mar 26, 2016 6:10:00 pm org.apache.catalina.startup.catalina start info: server startup in 4357 ms mar 26, 2016 6:10:50 pm org.apache.catalina.loader.webappclassloaderbase modified severe:     resource '/web-inf/classes/com/theka/desi/controllers/homecontroller.class' missing mar 26, 2016 6:10:50 pm org.apache.catalina.core.standardcontext reload info: reloading context name [/desi] has started mar 26, 2016 6:10:50 pm org.apache.catalina.core.applicationcontext log info: destroying spring frameworkservlet 'appservlet' mar 26, 2016 6:10:50 pm org.apache.catalina.core.applicationcontext log info: closing spring root webapplicationcontext mar 26, 2016 6:10:52 pm org.apache.catalina.startup.tldconfig execute info: @ least 1 jar scanned tlds yet contained no tlds. enable debug logging logger complete list of jars scanned no tlds found in them. skipping unneeded jars during scanning can improve startup time , jsp compilation time. mar 26, 2016 6:10:52 pm org.apache.catalina.core.applicationcontext log info: no spring webapplicationinitializer types detected on classpath mar 26, 2016 6:10:52 pm org.apache.catalina.core.applicationcontext log info: initializing spring root webapplicationcontext log4j:warn no appenders found logger (org.springframework.web.context.contextloader). log4j:warn please initialize log4j system properly. mar 26, 2016 6:10:53 pm org.apache.catalina.core.applicationcontext log info: initializing spring frameworkservlet 'appservlet' mar 26, 2016 6:10:53 pm org.apache.catalina.core.standardcontext reload info: reloading context name [/desi] completed 

deployment directory structure enter image description here

i ran project prject_> run as>run on server

when deploy default, if have 1 application deployed tomcat, context root '/'. unless have said /desi should using http://localhost:8080/


Comments