This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Spring and the fly likes Spring webMVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring webMVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound" Watch "Spring webMVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound" New topic
Author

Spring webMVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Hi All,

I am using the following example:


web.xml



application-config.xml



WelcomeController.java




when i am typing this url in browser http://localhost:8080/mvcdemoapp/helloWorld

i am getting the below error:

Mar 4, 2010 3:08:21 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound

WARNING: No mapping found for HTTP request with URI [/mvcdemoapp/helloWorld] in DispatcherServlet with name 'example'


Please some body guide me what is wrong with the above code.


Regards
Sudhakar
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Is that a correct URL pattern? Do you need an "*"?

<servlet-mapping>
<servlet-name>example</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
I think Mark's right...the path should probably be "/*"

Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Craig Walls wrote:I think Mark's right...the path should probably be "/*"



I changed it and still not working..

Here is the tomcat log:

Mar 5, 2010 10:53:22 AM 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\Java\jdk1.5.0_15\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\IBM\WebSphere MQ\Java\lib;D:\oracle\product\10.2.0\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\IBM\Trace Facility;C:\Program Files\Personal Communications;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files\Windows Imaging\;C:\Program Files\IBM\WebSphere MQ\bin;C:\Program Files\IBM\WebSphere MQ\tools\c\samples\bin;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.6.0_12\bin;C:\Program Files\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;C:\Program Files\jakarta-tomcat-5.0.28\common\lib\jsp-api.jar;.;C:\ANT\apache-ant-1.7.1\bin;C:\Program Files\CollabNet Subversion Client;C:\Program Files\glassfish-v2ur2\javadb\bin;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\apache-maven-2.2.1\bin;C:\Documents and Settings\149955\Desktop\gwt-windows-1.7.0\gwt-windows-1.7.0
Mar 5, 2010 10:53:22 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:mvcdemoapp' did not find a matching property.
Mar 5, 2010 10:53:23 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Mar 5, 2010 10:53:23 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2021 ms
Mar 5, 2010 10:53:23 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 5, 2010 10:53:23 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Mar 5, 2010 10:53:24 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'example'
Mar 5, 2010 10:53:24 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'example': initialization started
Mar 5, 2010 10:53:24 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'example-servlet': startup date [Fri Mar 05 10:53:24 GMT+05:30 2010]; root of context hierarchy
Mar 5, 2010 10:53:24 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/application-config.xml]
Mar 5, 2010 10:53:25 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@149d886: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor]; root of factory hierarchy
Mar 5, 2010 10:53:27 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'example': initialization completed in 3406 ms
Mar 5, 2010 10:53:27 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 5, 2010 10:53:27 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 5, 2010 10:53:27 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/47 config=null
Mar 5, 2010 10:53:27 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4862 ms
Mar 5, 2010 10:54:13 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/mvcdemoapp/helloWorld] in DispatcherServlet with name 'example'



and it is my POM.xml





What might be the problem?
Kuladip Yadav
Ranch Hand

Joined: Jul 30, 2008
Posts: 162

Hi,

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@149d886: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor];

above log suggest bean for WelcomeController is not created.

Also logs for registering handler are missing.

May be your WelcomeController class package and component-scan base-package in application-context.xml are different.
<context:component-scan base-package="com.mvcdemoapp"></context:component-scan>

Both should be exactly same.

Thanks.
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Kuldeep Yadav wrote:Hi,

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@149d886: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,
org.springframework.context.annotation.internalAutowiredAnnotationProcessor,
org.springframework.context.annotation.internalRequiredAnnotationProcessor,
org.springframework.context.annotation.internalCommonAnnotationProcessor];

above log suggest bean for WelcomeController is not created.

Also logs for registering handler are missing.

May be your WelcomeController class package and component-scan base-package in application-context.xml are different.
<context:component-scan base-package="com.mvcdemoapp"></context:component-scan>

Both should be exactly same.

Thanks.


Kuldeep, Thanks for your reply..

the package of WelcomeController.java and base-package value in application-config.xml is same.

I have spent whole day to find out the problem but no success..I am really going mad...Any help guys....
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

I found out that after i deployed the application in tomcat, The C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\mvcdemoapp\WEB-INF\classes\com\mvcdemoapp is empty...

I think it is supposed to have class file of WelcomeController.java..

what i am doing wrong?

I am using maven plugin for eclipse.

I am exporting the war file of the project to webapps folder of tomcat and running tomcat again.


Some body help me
Kuladip Yadav
Ranch Hand

Joined: Jul 30, 2008
Posts: 162

Hi Sudhakar,

If it is originally maven project then first convert it into eclipse WTP project
using :

And then import project in eclipse and try again.

Hopefully, it will work for you.

Thanks.
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Guys,

I found out the problem..the war file i am deploying in tomcat does not have class file of welcomecontroller.java

This happened because i am running maven commands in one location and my eclipse changes happening in one location..

at last i resolved this..

thanks guys..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Spring webMVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound
 
Similar Threads
Empty Ajax response with Spring 3 and jQuery
controller don't display view
Problem running app under Tomcat v7
Spring annotation no handler found
org.springframework.web.servlet.DispatcherServlet noHandlerFound