Announcement Announcement Module
Collapse
No announcement yet.
A simple spring mvc projects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • A simple spring mvc projects

    Ive written a simple mvc project using spring source tools .. but somehow its not running.. as a beginner I cant understand what is going on here... I got several exception..

    btw you can get my project frome here .

    please anyone check it..please




    modified project is here
    Last edited by rokon; Apr 6th, 2010, 11:24 PM. Reason: modified project link added.

  • #2
    Try to add follwoing code in your mvcconfig.xml
    HTML Code:
     <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="welcome.htm">welcome</prop>
    </props>
    </bean>
    
    <bean name="welcome"
              class="org.springframework.web.servlet.mvc.ParameterizableViewController"
              p:viewName="welcome" />
    modify your web.xml as follows

    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    
    	<!-- Enables clean URLs with JSP views e.g. /welcome instead of /app/welcome -->
    	
    		
    	<!-- Handles all requests into the application -->
    	<servlet>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>
    				/WEB-INF/spring/*.xml
    			</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    		
    	<!-- Maps all /app requests to the DispatcherServlet for handling -->
    	<servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet>
            <servlet-name>springmvc</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>*.htm</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>*.html</url-pattern>
        </servlet-mapping>
    	
    </web-app>

    Comment


    • #3
      Thank you very much..... I've modified my code as you suggested but still its not running....

      I could not understand why this is going on... could you please try it to run...

      My modified project is here

      Please bro try it... please !!!

      Comment


      • #4
        Whats the error you are getting ?
        Please update stracktrace here?

        Comment


        • #5
          strack-trace

          org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from ServletContext resource [/WEB-INF/springmvc-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml]
          at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:341)
          at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
          at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:143)
          at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:178)
          at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:149)
          at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:124)
          at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:93)
          at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:130)
          at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:465)
          at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:395)
          at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 43)
          at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 59)
          at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:340 )
          at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:307)
          at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
          at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
          at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1173)
          at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:993)
          at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4149)
          at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4458)
          at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
          at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:741)
          at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
          at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
          at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
          at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
          at org.apache.catalina.startup.Catalina.start(Catalin a.java:587)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:290)
          at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:415)
          Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml]
          at org.springframework.web.context.support.ServletCon textResource.getInputStream(ServletContextResource .java:118)
          at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:328)
          Last edited by rokon; Apr 6th, 2010, 11:30 PM.

          Comment


          • #6
            stack-trace

            EVERE: StandardWrapper.Throwable
            org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from ServletContext resource [/WEB-INF/springmvc-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml]
            at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:341)
            at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
            at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:143)
            at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:178)
            at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:149)
            at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:124)
            at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:93)
            at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:130)
            at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:465)
            at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:395)
            at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 43)
            at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 59)
            at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:340 )
            at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:307)
            at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
            at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
            at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1173)
            at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:993)
            at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4149)
            at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4458)
            at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
            at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:741)
            at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
            at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
            at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
            at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
            at org.apache.catalina.startup.Catalina.start(Catalin a.java:587)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:290)
            at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:415)
            Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml]
            at org.springframework.web.context.support.ServletCon textResource.getInputStream(ServletContextResource .java:118)
            at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:328)
            ... 32 more
            Apr 6, 2010 10:17:34 AM org.apache.catalina.core.StandardContext loadOnStartup
            SEVERE: Servlet /testMVC threw load() exception
            java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml]
            at org.springframework.web.context.support.ServletCon textResource.getInputStream(ServletContextResource .java:118)
            at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:328)
            at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
            at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:143)
            at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:178)
            at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:149)
            at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:124)
            at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:93)
            at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:130)
            at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:465)
            at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:395)
            at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 43)
            at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 59)
            at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:340 )
            at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:307)
            at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
            at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
            at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1173)
            at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:993)
            at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4149)
            at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4458)
            at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
            at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:741)
            at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
            at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
            at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
            at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
            at org.apache.catalina.startup.Catalina.start(Catalin a.java:587)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:290)
            at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:415)

            Comment


            • #7
              its becuase your dispatcher servlet and spring mvc servlet is not finding . both should be created in web-inf\ folder

              create springmvc-servlet.xml and disptacher-servlet.xml


              HTML Code:
              <?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:aop="http://www.springframework.org/schema/aop"
                     xmlns:tx="http://www.springframework.org/schema/tx"
                     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
              http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
                 
              
                  <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                      <property name="mappings">

              Comment

              Working...
              X