title: Spring oauth2 ver 2.0.7, 404 error on endpoint /oauth/token
body: <p>I got problem when try to integrate our web app with Spring oauth2<br>
  the end point /oauth/token is mapped for both GET and POST method</p>
  
  <pre><code>o.s.s.o.p.e.FrameworkEndpointHandlerMapping- Mapped "{[/oauth/token],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity&lt;org.springframework.security.oauth2.common.OAuth2AccessToken&gt; org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.getAccessToken(java.security.Principal,java.util.Map&lt;java.lang.String, java.lang.String&gt;) throws org.springframework.web.HttpRequestMethodNotSupportedException
  o.s.s.o.p.e.FrameworkEndpointHandlerMapping- Mapped "{[/oauth/token],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity&lt;org.springframework.security.oauth2.common.OAuth2AccessToken&gt; org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(java.security.Principal,java.util.Map&lt;java.lang.String, java.lang.String&gt;) throws org.springframework.web.HttpRequestMethodNotSupportedException
  </code></pre>
  
  <p><strong>when access</strong>: <a href="https://192.168.70.19:8072/oauth/token?grant_type=password&amp;client_id=7CA42EA39288EC73212716FC6A51B8A2&amp;username=admin&amp;password=switch" rel="nofollow">https://192.168.70.19:8072/oauth/token?grant_type=password&amp;client_id=7CA42EA39288EC73212716FC6A51B8A2&amp;username=admin&amp;password=switch</a></p>
  
  <p>**server return:**Bad client credentials</p>
  
  <p>its ok, however when I add the client_secret
  <a href="https://192.168.70.19:8072/oauth/token?grant_type=password&amp;client_id=7CA42EA39288EC73212716FC6A51B8A2&amp;client_secret=client_secret&amp;username=admin&amp;password=switch" rel="nofollow">https://192.168.70.19:8072/oauth/token?grant_type=password&amp;client_id=7CA42EA39288EC73212716FC6A51B8A2&amp;client_secret=client_secret&amp;username=admin&amp;password=switch</a></p>
  
  <p><strong>server return</strong> 404 error (as I know this should happen when the API is not mapped only)</p>
  
  <p>Some of my configuration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:security="http://www.springframework.org/schema/security"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://www.springframework.org/schema/security
      http://www.springframework.org/schema/security/spring-security-3.2.xsd
      http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
      http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"&gt;
  
      &lt;bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt;
          &lt;property name="targetClass"
                    value="org.springframework.security.core.context.SecurityContextHolder" /&gt;
          &lt;property name="targetMethod" value="setStrategyName" /&gt;
          &lt;property name="arguments"&gt;
              &lt;list&gt;
                  &lt;value&gt;MODE_INHERITABLETHREADLOCAL&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="authenticationEntryPoint"
            class="com.alu.ov.ngnms.appserver.login.AuthenticationEntryPoint"&gt;
          &lt;constructor-arg name="loginUrl" value="/login.html" /&gt;
      &lt;/bean&gt;
      &lt;bean name="customUserDetailsAuthenticationProvider" class="com.alu.ov.ngnms.appserver.login.CustomUserDetailsAuthenticationProvider"&gt;
          &lt;property name="aaaServerRepository" ref="AAAServerRepository"&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;security:authentication-manager alias="authenticationManager"
                                       erase-credentials="false"&gt;
               &lt;security:authentication-provider ref="customUserDetailsAuthenticationProvider" /&gt;
      &lt;/security:authentication-manager&gt;
      &lt;bean id="checkTokenEndPoint"
            class="org.springframework.security.oauth2.provider.endpoint.CheckTokenEndpoint"&gt;
          &lt;constructor-arg name="resourceServerTokenServices" ref="tokenServices"/&gt;      
      &lt;/bean&gt;
      &lt;bean id="customAccessDeniedHandler"
            class="com.alu.ov.ngnms.appserver.login.CustomAccessDeniedHandler"&gt;&lt;/bean&gt;
  
      &lt;security:http pattern="/oauth/token" create-session="stateless" entry-point-ref="authenticationEntryPoint" authentication-manager-ref="clientAuthenticationManager"&gt;
          &lt;security:intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" /&gt;
          &lt;security:anonymous enabled="false" /&gt;
          &lt;security:custom-filter ref="clientCredentialsTokenEndpointFilter" after="BASIC_AUTH_FILTER" /&gt;
          &lt;security:access-denied-handler ref="customAccessDeniedHandler" /&gt;
      &lt;/security:http&gt;
  
      &lt;security:http use-expressions="true" entry-point-ref="authenticationEntryPoint" create-session="never"&gt;
          &lt;!-- for all users (login &amp; non-login) --&gt;
          &lt;security:intercept-url pattern="/favicon.ico" access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/bower_components/**" access="permitAll"/&gt;
          &lt;security:intercept-url pattern="/locales/**" access="permitAll"/&gt;
          &lt;security:intercept-url pattern="/ov_components/**" access="permitAll"/&gt;
          &lt;security:intercept-url pattern="/scripts/**" access="permitAll"/&gt;
          &lt;security:intercept-url pattern="/styles/**" access="permitAll"/&gt;
          &lt;security:intercept-url pattern="/template/**" access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/webstart/classes/**" access="permitAll" /&gt;
          &lt;security:intercept-url pattern="/assets/**" access="permitAll" /&gt;
  
          &lt;!-- only for non-login users --&gt;
          &lt;security:intercept-url pattern="/login.html" access="!isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/upgrade.html" access="!isAuthenticated()" /&gt;
          &lt;security:intercept-url pattern="/api/login" access="!isAuthenticated()" /&gt;
  
          &lt;!-- for all login users --&gt;
  
          &lt;!-- only for admin user &amp; no-license OV --&gt;
          &lt;security:intercept-url pattern="/noLicense.html" access="hasAnyRole('ROLE_ADMIN_NO_LICENSE')" /&gt;
  
          &lt;security:intercept-url pattern="/**" access="isAuthenticated() and !hasRole('ROLE_ADMIN_NO_LICENSE')" /&gt;
          &lt;security:access-denied-handler ref="customAccessDeniedHandler"/&gt;
          &lt;!-- Add filter to extract access token from request and perform authentication --&gt;
          &lt;security:custom-filter ref="customOAuth2AuthenProcessingFilter" before="PRE_AUTH_FILTER" /&gt;
          &lt;security:expression-handler ref="oauthWebExpressionHandler" /&gt;
      &lt;/security:http&gt;
  
      &lt;bean id="clientCredentialsTokenEndpointFilter" class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter"&gt;
          &lt;property name="authenticationManager" ref="clientAuthenticationManager" /&gt;
      &lt;/bean&gt;
  
         &lt;security:global-method-security authentication-manager-ref="authenticationManager" pre-post-annotations="enabled"
          secured-annotations="enabled"&gt;
      &lt;/security:global-method-security&gt;
  
          &lt;oauth:authorization-server client-details-service-ref="clientDetails" token-services-ref="tokenServices"&gt;
          &lt;oauth:authorization-code /&gt;
          &lt;oauth:implicit /&gt;
          &lt;oauth:refresh-token /&gt;
          &lt;oauth:client-credentials /&gt;
          &lt;oauth:password authentication-manager-ref="authenticationManager"/&gt;
  
      &lt;/oauth:authorization-server&gt;
      &lt;security:authentication-manager id="clientAuthenticationManager"&gt;
          &lt;security:authentication-provider user-service-ref="clientDetailsUserService" /&gt;
      &lt;/security:authentication-manager&gt;
  
      &lt;bean id="clientDetailsUserService" class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService"&gt;
          &lt;constructor-arg ref="clientDetails" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices" &gt;
          &lt;property name="tokenStore" ref="mongoDBTokenStore" /&gt;
          &lt;property name="supportRefreshToken" value="true" /&gt;
          &lt;property name="clientDetailsService" ref="clientDetails" /&gt;
          &lt;!--  Access token &amp; Refresh token will be expired in 1 year 1 second after being granted --&gt;
          &lt;property name="accessTokenValiditySeconds" value="31536001"&gt;&lt;/property&gt;
          &lt;property name="refreshTokenValiditySeconds" value="31536001"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="ovTokenExtractor" class="com.alu.ov.ngnms.appserver.login.OVTokenExtractor"&gt;&lt;/bean&gt;
      &lt;bean id="oauth2AuthenticationManager" class="org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager"&gt;
          &lt;property name="tokenServices" ref="tokenServices"&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="customOAuth2AuthenProcessingFilter" class="org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter"&gt;
          &lt;property name="authenticationEntryPoint" ref="authenticationEntryPoint"&gt;&lt;/property&gt;
          &lt;property name="authenticationManager" ref="oauth2AuthenticationManager"&gt;&lt;/property&gt;
          &lt;property name="tokenExtractor" ref="ovTokenExtractor"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="clientDetails" class="com.alu.ov.ngnms.appserver.token.CustomClientDetailsService"/&gt;
  
      &lt;security:global-method-security pre-post-annotations="enabled" proxy-target-class="true"&gt;
          &lt;!--you could also wire in the expression handler up at the layer of the http filters. See https://jira.springsource.org/browse/SEC-1452 --&gt;
          &lt;security:expression-handler ref="oauthExpressionHandler" /&gt;
      &lt;/security:global-method-security&gt;
  
      &lt;oauth:expression-handler id="oauthExpressionHandler" /&gt;
  
      &lt;mvc:annotation-driven /&gt;
  
      &lt;mvc:default-servlet-handler /&gt;
  
      &lt;oauth:web-expression-handler id="oauthWebExpressionHandler" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>--------EDIT 1--------
  added web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
          &lt;servlet-name&gt;atmoSpring&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.atmosphere.cpr.MeteorServlet&lt;/servlet-class&gt;
  
  
          &lt;init-param&gt;
              &lt;!-- When MeteorServlet is used, this is the parameter that will be looked 
                  and all requests will be delegated to this servlet, Of course, since we are 
                  using, Spring MVC, we delegate to DispatcherServlet --&gt;
              &lt;param-name&gt;org.atmosphere.servlet&lt;/param-name&gt;
              &lt;param-value&gt;org.springframework.web.servlet.DispatcherServlet&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;!-- Bunch of Atmosphere specific properties --&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.cpr.broadcasterClass&lt;/param-name&gt;
              &lt;param-value&gt;org.atmosphere.cpr.DefaultBroadcaster&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;!-- Set Atmosphere to use the container native Comet support. --&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.useNative&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;!-- Force Atmosphere to use stream when writing bytes. --&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.useStream&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.cpr.AtmosphereInterceptor&lt;/param-name&gt;
              &lt;param-value&gt;org.atmosphere.interceptor.SSEAtmosphereInterceptor&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.interceptor.SSEAtmosphereInterceptor.contentType&lt;/param-name&gt;
              &lt;param-value&gt;text/event-stream&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;!-- Use this interceptor to prevent firewall/proxies from canceling the 
              connection after a specific idle time --&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.cpr.AtmosphereInterceptor&lt;/param-name&gt;
              &lt;param-value&gt;org.atmosphere.interceptor.HeartbeatInterceptor&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.interceptor.HeartbeatInterceptor.heartbeatFrequencyInSeconds&lt;/param-name&gt;
              &lt;param-value&gt;30&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.useWebSocketAndServlet3&lt;/param-name&gt;
              &lt;param-value&gt;false&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.cpr.broadcasterCacheClass&lt;/param-name&gt;
              &lt;param-value&gt;org.atmosphere.cache.UUIDBroadcasterCache&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.cpr.broadcaster.shareableThreadPool&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
  
          &lt;init-param&gt;
              &lt;param-name&gt;org.atmosphere.cpr.sessionSupport&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
          &lt;async-supported&gt;true&lt;/async-supported&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;atmoSpring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/webContext.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Spring Security --&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
          &lt;async-supported&gt;true&lt;/async-supported&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextAttribute&lt;/param-name&gt;
              &lt;param-value&gt;org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
          &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt; 
          &lt;dispatcher&gt;ASYNC&lt;/dispatcher&gt;
          &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;
      &lt;/filter-mapping&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;cacheControlFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
          &lt;async-supported&gt;true&lt;/async-supported&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;cacheControlFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;!-- Session Listener for Webstart --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;com.alu.ov.ngnms.appserver.controller.SessionListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  </code></pre>