Announcement Announcement Module
Collapse
No announcement yet.
WARN org.springframework.web.servlet.DispatcherServlet. noHandlerFound Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • WARN org.springframework.web.servlet.DispatcherServlet. noHandlerFound

    I am adding a JSP controller and page to a web service which has up until now been used to return JSON rest resources. At any rate I am getting 404 when accessing the jsp page and the logs are saying noHandlerFound even though my controller method is actually being invoked and returning a model and view.

    I have spent most of the day trying to figure out what is happening here and am making 0 progress. Anyone got any ideas?

    Here are logs generated during one of the failed requests:

    Code:
    2013-03-21 15:37:45,020 DEBUG org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:823) [http-bio-8080-exec-10] - DispatcherServlet with name 'spring' processing GET request for [/cool-matcher-service/jsp/importWadlWizard]
    2013-03-21 15:37:45,020 DEBUG org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:219) [http-bio-8080-exec-10] - Looking up handler method for path /jsp/importWadlWizard
    2013-03-21 15:37:45,021 DEBUG org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:226) [http-bio-8080-exec-10] - Returning handler method [public org.springframework.web.servlet.ModelAndView com.doitnext.cms.controller.JspController.handleImportWadlWizardGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException]
    2013-03-21 15:37:45,021 DEBUG org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) [http-bio-8080-exec-10] - Returning cached instance of singleton bean 'jspController'
    2013-03-21 15:37:45,021 DEBUG org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:912) [http-bio-8080-exec-10] - Last-Modified value for [/cool-matcher-service/jsp/importWadlWizard] is: -1
    2013-03-21 15:37:45,021 DEBUG com.doitnext.cms.controller.JspController.handleImportWadlWizardGet(JspController.java:27) [http-bio-8080-exec-10] - returning importWadlWizard
    2013-03-21 15:37:45,022 DEBUG org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1206) [http-bio-8080-exec-10] - Rendering view [org.springframework.web.servlet.view.JstlView: name 'importWadlWizard'; URL [/WEB-INF/jsp/importWadlWizard.jsp]] in DispatcherServlet with name 'spring'
    2013-03-21 15:37:45,022 DEBUG org.springframework.web.servlet.view.AbstractView.exposeModelAsRequestAttributes(AbstractView.java:373) [http-bio-8080-exec-10] - Added model object 'cms' of type [java.util.HashMap] to request in view with name 'importWadlWizard'
    2013-03-21 15:37:45,022 DEBUG org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:236) [http-bio-8080-exec-10] - Forwarding to resource [/WEB-INF/jsp/importWadlWizard.jsp] in InternalResourceView 'importWadlWizard'
    2013-03-21 15:37:45,022 DEBUG org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:823) [http-bio-8080-exec-10] - DispatcherServlet with name 'spring' processing GET request for [/cool-matcher-service/WEB-INF/jsp/importWadlWizard.jsp]
    2013-03-21 15:37:45,023 DEBUG org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:219) [http-bio-8080-exec-10] - Looking up handler method for path /WEB-INF/jsp/importWadlWizard.jsp
    2013-03-21 15:37:45,029 DEBUG org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:229) [http-bio-8080-exec-10] - Did not find handler method for [/WEB-INF/jsp/importWadlWizard.jsp]
    2013-03-21 15:37:45,030 WARN org.springframework.web.servlet.DispatcherServlet.noHandlerFound(DispatcherServlet.java:1108) [http-bio-8080-exec-10] - No mapping found for HTTP request with URI [/cool-matcher-service/WEB-INF/jsp/importWadlWizard.jsp] in DispatcherServlet with name 'spring'
    2013-03-21 15:37:45,030 DEBUG org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951) [http-bio-8080-exec-10] - Successfully completed request
    2013-03-21 15:37:45,030 DEBUG org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951) [http-bio-8080-exec-10] - Successfully completed request
    Here is the code for the controller:

    Code:
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.Map;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.apache.log4j.Logger;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.servlet.ModelAndView;
    
    import com.doitnext.cms.domain.AuthorizationInfo;
    
    @Controller
    @RequestMapping("/jsp")
    public class JspController {
    	protected final Logger logger = Logger.getLogger(getClass());
    	
    	@RequestMapping(value = "/importWadlWizard", method = RequestMethod.GET)
    	public ModelAndView handleImportWadlWizardGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            logger.debug("returning importWadlWizard");
    
            Map<String, Object> myModel = new HashMap<String, Object>();
            AuthorizationInfo ai = (AuthorizationInfo) request.getAttribute(AuthorizationInfo.getAttributeKey());
    
            myModel.put("authorizationInfo", ai);
            
            return new ModelAndView("importWadlWizard", "cms", myModel);
        }
    	
    }

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
    	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
    	<display-name>Cool Matcher Service</display-name>
    
    	<context-param>
    		<param-name>webAppRootKey</param-name>
    		<param-value>ft.cms.rest.root</param-value>
    	</context-param>
    
    	<context-param>
    		<param-name>propfile</param-name>
    		<param-value>cool-matcher-service.properties</param-value>
    	</context-param>
    
    	<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>/*</url-pattern>
    	</servlet-mapping>
    
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    </web-app>
    Here is the spring-servlet.xml:
    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" 
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	   		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    	
    	<!-- Declare a view resolver -->
    	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        	<property name="prefix" value="/WEB-INF/jsp/" />
        	<property name="suffix" value=".jsp" />
    	</bean>
    
    </beans>

  • #2
    Additional logging info

    I turned up the logging to TRACE to get additional info on the request processing. Due to the limitations on the post size I am removing the front half of the logging and only showing what happens after my controller method is called.

    Code:
    2013-03-21 16:26:48,408 DEBUG com.doitnext.cms.controller.JspController.handleImportWadlWizardGet(JspController.java:27) [http-bio-8080-exec-3] - returning importWadlWizard
    2013-03-21 16:26:48,409 TRACE org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:135) [http-bio-8080-exec-3] - Method [handleImportWadlWizardGet] returned [ModelAndView: reference to view with name 'importWadlWizard'; model is {cms={authorizationInfo=null}}]
    2013-03-21 16:26:48,409 TRACE org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(HandlerMethodReturnValueHandlerComposite.java:78) [http-bio-8080-exec-3] - Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.ModelAndViewMethodReturnValueHandler@219c148c] supports [class org.springframework.web.servlet.ModelAndView]
    2013-03-21 16:26:48,412 DEBUG org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1529) [http-bio-8080-exec-3] - Invoking afterPropertiesSet() on bean with name 'importWadlWizard'
    2013-03-21 16:26:48,412 TRACE org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:133) [http-bio-8080-exec-3] - Cached view [importWadlWizard]
    2013-03-21 16:26:48,412 DEBUG org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1206) [http-bio-8080-exec-3] - Rendering view [org.springframework.web.servlet.view.JstlView: name 'importWadlWizard'; URL [/WEB-INF/jsp/importWadlWizard.jsp]] in DispatcherServlet with name 'spring'
    2013-03-21 16:26:48,412 TRACE org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:257) [http-bio-8080-exec-3] - Rendering view with name 'importWadlWizard' with model {cms={authorizationInfo=null}} and static attributes {}
    2013-03-21 16:26:48,413 DEBUG org.springframework.web.servlet.view.AbstractView.exposeModelAsRequestAttributes(AbstractView.java:373) [http-bio-8080-exec-3] - Added model object 'cms' of type [java.util.HashMap] to request in view with name 'importWadlWizard'
    2013-03-21 16:26:48,447 DEBUG org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:236) [http-bio-8080-exec-3] - Forwarding to resource [/WEB-INF/jsp/importWadlWizard.jsp] in InternalResourceView 'importWadlWizard'
    2013-03-21 16:26:48,451 TRACE org.springframework.web.servlet.FrameworkServlet.initContextHolders(FrameworkServlet.java:986) [http-bio-8080-exec-3] - Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@49d5c12
    2013-03-21 16:26:48,451 DEBUG org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:823) [http-bio-8080-exec-3] - DispatcherServlet with name 'spring' processing GET request for [/cool-matcher-service/WEB-INF/jsp/importWadlWizard.jsp]
    2013-03-21 16:26:48,451 TRACE org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1088) [http-bio-8080-exec-3] - Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@490f9b9a] in DispatcherServlet with name 'spring'
    2013-03-21 16:26:48,452 DEBUG org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:219) [http-bio-8080-exec-3] - Looking up handler method for path /WEB-INF/jsp/importWadlWizard.jsp
    2013-03-21 16:26:48,455 TRACE org.springframework.web.accept.PathExtensionContentNegotiationStrategy$JafMediaTypeFactory.initFileTypeMap(PathExtensionContentNegotiationStrategy.java:162) [http-bio-8080-exec-3] - Loading default Java Activation Framework FileTypeMap
    2013-03-21 16:26:48,467 DEBUG org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:229) [http-bio-8080-exec-3] - Did not find handler method for [/WEB-INF/jsp/importWadlWizard.jsp]
    2013-03-21 16:26:48,468 TRACE org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1088) [http-bio-8080-exec-3] - Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@6c4e07f5] in DispatcherServlet with name 'spring'
    2013-03-21 16:26:48,468 TRACE org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.getHandlerInternal(AbstractUrlHandlerMapping.java:127) [http-bio-8080-exec-3] - No handler mapping found for [/WEB-INF/jsp/importWadlWizard.jsp]
    2013-03-21 16:26:48,468 WARN org.springframework.web.servlet.DispatcherServlet.noHandlerFound(DispatcherServlet.java:1108) [http-bio-8080-exec-3] - No mapping found for HTTP request with URI [/cool-matcher-service/WEB-INF/jsp/importWadlWizard.jsp] in DispatcherServlet with name 'spring'
    2013-03-21 16:26:48,469 TRACE org.springframework.web.servlet.FrameworkServlet.resetContextHolders(FrameworkServlet.java:996) [http-bio-8080-exec-3] - Cleared thread-bound request context: org.apache.catalina.core.ApplicationHttpRequest@49d5c12
    2013-03-21 16:26:48,469 DEBUG org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951) [http-bio-8080-exec-3] - Successfully completed request
    2013-03-21 16:26:48,469 TRACE org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:332) [http-bio-8080-exec-3] - Publishing event in WebApplicationContext for namespace 'spring-servlet': ServletRequestHandledEvent: url=[/cool-matcher-service/WEB-INF/jsp/importWadlWizard.jsp]; client=[127.0.0.1]; method=[GET]; servlet=[spring]; session=[null]; user=[null]; time=[18ms]; status=[OK]
    2013-03-21 16:26:48,469 TRACE org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:332) [http-bio-8080-exec-3] - Publishing event in Root WebApplicationContext: ServletRequestHandledEvent: url=[/cool-matcher-service/WEB-INF/jsp/importWadlWizard.jsp]; client=[127.0.0.1]; method=[GET]; servlet=[spring]; session=[null]; user=[null]; time=[18ms]; status=[OK]
    2013-03-21 16:26:48,469 TRACE org.springframework.web.servlet.FrameworkServlet.resetContextHolders(FrameworkServlet.java:996) [http-bio-8080-exec-3] - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@64d9013e
    2013-03-21 16:26:48,470 DEBUG org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951) [http-bio-8080-exec-3] - Successfully completed request
    2013-03-21 16:26:48,470 TRACE org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:332) [http-bio-8080-exec-3] - Publishing event in WebApplicationContext for namespace 'spring-servlet': ServletRequestHandledEvent: url=[/cool-matcher-service/jsp/importWadlWizard]; client=[127.0.0.1]; method=[GET]; servlet=[spring]; session=[null]; user=[null]; time=[143ms]; status=[OK]
    2013-03-21 16:26:48,470 TRACE org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:332) [http-bio-8080-exec-3] - Publishing event in Root WebApplicationContext: ServletRequestHandledEvent: url=[/cool-matcher-service/jsp/importWadlWizard]; client=[127.0.0.1]; method=[GET]; servlet=[spring]; session=[null]; user=[null]; time=[143ms]; status=[OK]

    Comment


    • #3
      Have you READ the message?

      Code:
      2013-03-21 16:26:48,468 WARN org.springframework.web.servlet.DispatcherServlet.noHandlerFound(DispatcherServlet.java:1108) [http-bio-8080-exec-3] - No mapping found for HTTP request with URI [/cool-matcher-service/WEB-INF/jsp/importWadlWizard.jsp] in DispatcherServlet with name 'spring'
      It has nothing to do with your handler... The fact is due to your mapping (/*) the request for rendering the JSP is also passing through the spring dispatcher servlet, which obviously will not handle this becuase there is no handler for rendering that JSP. Eventually this request will be handled by the container default servlet and the page will be rendered.

      Comment


      • #4
        Marten, thank you for your reply and for clarifying what the message means. I did read the message but it did not make any sense to me. Your explanation provides important amplifying information. So to summarize what you are saying I can't map all requests through the DispatcherServlet because when my handler returns a model and view, the framework re routes the request back through the front end to fetch the jsp page rather than simply opening up a resource and rendering the page (correct?).

        I modified my web.xml from:

        Code:
        	<servlet-mapping>
        		<servlet-name>spring</servlet-name>
        		<url-pattern>/*</url-pattern>
        	</servlet-mapping>
        Code:
        	<servlet-mapping>
        		<servlet-name>spring</servlet-name>
        		<url-pattern>/rest/*</url-pattern>
        	</servlet-mapping>
        And by hitting my existing resources with "http://localhost:8080/cool-matcher-service/rest/v1/..." I am able to make them work and I can hit "http://localhost:8080/cool-matcher-service/rest/jsp/importWadlWizard" but the content type is not being sent and it renders in the browser as JSP source. I am not sure why. I would have thought that the mappings in <tomcat-root>/conf/web.xml

        which includes:
        Code:
           <!-- The mappings for the JSP servlet -->
            <servlet-mapping>
                <servlet-name>jsp</servlet-name>
                <url-pattern>*.jsp</url-pattern>
                <url-pattern>*.jspx</url-pattern>
            </servlet-mapping>
        Would have properly handled the jsp page.
        Last edited by steowens; Mar 22nd, 2013, 01:39 PM.

        Comment


        • #5
          You can still map the servlet to /* (or / if you want). Spring comes with a DefaultServletHttpRequestHandler for this, which can be easily configured with the mvc namespace. That should make things work.

          Although it is strange that switching the mapping doesn't fix it already, the page should be rendered just as is. At least that is what happend the last 10 years I worked with Spring .

          Comment


          • #6
            As it turns out the web.xml in your app directory precedes the web.xml in the <tomcat-root>/conf directory. To fix this, I copied the definitions for the default and the jsp serlets along with the servlet mappings into my web.xml and then put the mappings for the jsp and default handlers before my mapping to /*. This fixed the problem.

            Comment

            Working...
            X