Spring MVC - Annotation-based controller could not find the request handler method

This stopped working after adding Spring Security Filter.

Spring 3.1.4.RELEASE
Spring Security 3.1.2.RELEASE
Tomcat 7.0.37

The display is configured as expected when the application is deployed.

  INFO annotation.RequestMappingHandlerMapping: Mapped "{[/ countries], methods = [GET], params = [! CountryCode], headers = [], consumes = [], produces = [application / json], custom = []}" onto public com.purpleleaf.proxy.rest.data.ProxyResponse com.purpleleaf.proxy.rest.service.reference.DefaultCountry.findAll ()

GET request submitted.

  GET http: // localhost: 8081 / purpleleaf-admin-1.0.0 / countries? Page = 1 & start = 0 & limit = 25

Request parameters are added by ExtJS, and this is not a problem, since it works without security.

GET Request Log

 DEBUG util.AntPathRequestMatcher: Checking match of request: '/ countries';  against '/ *' DEBUG web.FilterChainProxy: / countries? page = 1 & start = 0 & limit = 25 has an empty filter list DEBUG servlet.DispatcherServlet: DispatcherServlet with name 'admin-spring' processing GET request for [//purpleleaf-admin-1.0 .0 / countries] DEBUG annotation.RequestMappingHandlerMapping: Did not find handler method for [//purpleleaf-admin-1.0.0/countries ] DEBUG handler.SimpleUrlHandlerMapping: URI Template variables for request [//purpleleaf-admin-1.0.0/ | DEBUG handler.SimpleUrlHandlerMapping: Matching patterns for request [//purpleleaf-admin-1.0.0/countries] are countries] are {} DEBUG handler.SimpleUrlHandlerMapping: Mapping [//purpleleaf-admin-1.0.0/countries] to HandlerExecutionChain with handler [org.spring framework.web.servlet.resource.DefaultServletHttpRequestHandler@ 3f8050cf] and 1 interceptor DEBUG servlet.DispatcherServlet: Last-Modified value for [//purpleleaf-admin-1.0.0/countries] is: -1 DEBUG servl  et.DispatcherServlet: Null ModelAndView returned to DispatcherServlet with name 'admin-spring': assuming HandlerAdapter completed request handling DEBUG servlet.DispatcherServlet: Successfully completed request 

When the request is processed by web.filterChainProxy, it is / countries , but when it is a process by annotation. RequestMappingHandlerMapping is //purpleleaf-admin-1.0.0/countires

purpleleaf-admin-1.0.0 is the folder in which the war file is inactive.

web.xml has the following display of servlets and filters

<servlet-mapping> <servlet-name>admin-spring</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

Any suggestion on how I can resolve this mapping?

Edit 1: Spring Security Configuration File

 <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="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-3.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <beans:import resource="classpath*:applicationContext-CrowdClient.xml" /> <beans:bean id="crowdUserDetailsService" class="com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsServiceImpl"> <beans:property name="authenticationManager" ref="crowdAuthenticationManager"/> <beans:property name="groupMembershipManager" ref="crowdGroupMembershipManager"/> <beans:property name="userManager" ref="crowdUserManager"/> <beans:property name="authorityPrefix" value="ROLE_"/> </beans:bean> <beans:bean id="crowdAuthenticationProvider" class="com.atlassian.crowd.integration.springsecurity.RemoteCrowdAuthenticationProvider"> <beans:constructor-arg ref="crowdAuthenticationManager"/> <beans:constructor-arg ref="httpAuthenticator"/> <beans:constructor-arg ref="crowdUserDetailsService"/> </beans:bean> <authentication-manager alias="authenticationManager"> <authentication-provider ref='crowdAuthenticationProvider' /> </authentication-manager> <beans:bean id="crowdAuthenticationProcessingFilterEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"> <beans:constructor-arg value="/login.jsp" /> </beans:bean> <beans:bean id="crowdAuthenticationProcessingFilter" class="com.atlassian.crowd.integration.springsecurity.CrowdSSOAuthenticationProcessingFilter"> <beans:property name="httpAuthenticator" ref="httpAuthenticator"/> <beans:property name="authenticationManager" ref="authenticationManager"/> <beans:property name="filterProcessesUrl" value="/j_security_check"/> <beans:property name="authenticationFailureHandler"> <beans:bean class="com.atlassian.crowd.integration.springsecurity.UsernameStoringAuthenticationFailureHandler"> <beans:property name="defaultFailureUrl" value="/login.jsp?error=true"/> </beans:bean> </beans:property> <beans:property name="authenticationSuccessHandler"> <beans:bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"> <beans:property name="defaultTargetUrl" value="/"/> </beans:bean> </beans:property> </beans:bean> <beans:bean id="crowdLogoutHandler" class="com.atlassian.crowd.integration.springsecurity.CrowdLogoutHandler"> <beans:property name="httpAuthenticator" ref="httpAuthenticator"/> </beans:bean> <beans:bean id="securityContextLogoutHandler" class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" /> <beans:bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"> <beans:constructor-arg index="0" value="/index.html"/> <beans:constructor-arg index="1"> <beans:list> <beans:ref bean="crowdLogoutHandler"/> <beans:ref bean="securityContextLogoutHandler"/> </beans:list> </beans:constructor-arg> <beans:property name="filterProcessesUrl" value="/logout.html"/> </beans:bean> <http pattern='/*' security='none'/> <!--http pattern='/scripts/*' security='none'/--> <http auto-config="false" entry-point-ref="crowdAuthenticationProcessingFilterEntryPoint"> <custom-filter position="FORM_LOGIN_FILTER" ref='crowdAuthenticationProcessingFilter'/> <custom-filter position="LOGOUT_FILTER" ref='logoutFilter'/> <!--intercept-url pattern="/admin/*" access="ROLE_application-administrators"/--> <!--intercept-url pattern="/passwordHint.html" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/--> <!--security:intercept-url pattern="/**/*.html*" access="IS_AUTHENTICATED_FULLY"/--> </http> </beans:beans> 
0
source share
1 answer

The root cause was purpleleaf-admin- 1.0.0 on the url. util.AntPathRequestMatcher was unable to resolve the path correctly when it contains a period (.).

The class was not in the path until a security filter was added.

0
source

All Articles