Oauth2和Spring-Security:java.lang.IllegalStateException:没有找到WebApplicationContext:没有注册ContextLoaderListener? [英] Oauth2 and Spring-Security: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?

查看:159
本文介绍了Oauth2和Spring-Security:java.lang.IllegalStateException:没有找到WebApplicationContext:没有注册ContextLoaderListener?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Oauth2与spring-security来安全的我的休息服务。我正在使用最新版本的oauth2和spring-security依赖项。以下是我的依赖关系:

 <! -  Spring Security Dependencies  - > 
< dependency>
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-core< / artifactId>
< / dependency>
< dependency>
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-web< / artifactId>
< / dependency>
< dependency>
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-config< / artifactId>
< / dependency>
< dependency>
< groupId> org.springframework.security.oauth< / groupId>
< artifactId> spring-security-oauth2< / artifactId>
< / dependency>核心Spring和Spring Web依赖关系的
<! - END

我正在使用maven多模块项目。所以在父pom中声明的依赖关系的版本。以下是依赖的版本:

 < spring-security-oauth2> 2.0.1.RELEASE< / spring-security-的oauth2> 
< spring.security.version> 3.2.4.RELEASE< /spring.security.version>

我的 Spring-security-aouth2.xml 配置文件如下:

 <?xml version =1.0encoding =UTF-8?> 
< beans xmlns =http://www.springframework.org/schema/beans
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexmlns :oauth =http://www.springframework.org/schema/security/oauth2
xmlns:sec =http://www.springframework.org/schema/securityxmlns:mvc =http: //www.springframework.org/schema/mvc
xsi:schemaLocation =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
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd>

<! - 创建用于从数据库管理客户端详细信息的客户端详细信息 - >
<! - JdbcClientDetailsS​​ervice提供从oauth_client_details表中获取
的默认实现另外,我们需要创建我们的
自定义类,实现ClientDetailsS​​ervice接口并覆盖其
loadClientByClientId方法 - >
< bean id =clientDetails
class =org.springframework.security.oauth2.provider.client.JdbcClientDetailsS​​ervice>
< constructor-arg index =0>
< ref bean =dataSource/>
< / constructor-arg>
< / bean>

<! - 配置验证管理器 - >
< bean id =passwordEncoder
class =org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder>
< constructor-arg name =strengthvalue =11/>
< / bean>

<! - 此类是Spring提供的UserDetailSerive Interface
的自定义实现,我们需要实现和覆盖其方法。
但是对于Oauth春天,我们提供了ClientDetailsUserDetailsS​​ervice,它已经
实现了UserDetailSerive Interface并覆盖了它的方法。 - >
< bean id =clientDetailsUserService
class =org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsS​​ervice>
< constructor-arg ref =clientDetails/>
< property name =passwordEncoderref =passwordEncoder>< / property>
< / bean>

<! - < bean id =oauthDaoAuthenticationProviderclass =org.springframework.security.authentication.dao.DaoAuthenticationProvider>
< property name =passwordEncoderref =passwordEncoder/> < property name =userDetailsS​​ervice
ref =clientDetailsUserService/> < /豆腐> - >

< sec:authentication-manager id =authenticationManager>
< sec:authentication-provider
user-service-ref =clientDetailsUserService/>
< / sec:authentication-manager>

<! - 使用数据库的Oauth令牌服务 - >
<! - JdbcTokenStore类从访问
提供来自数据库的令牌的默认实现。如果我们要自定义JDBC实现
,我们需要实现TokenStore接口并覆盖其方法 - >
< bean id =tokenStore
class =org.springframework.security.oauth2.provider.token.store.JdbcTokenStore>
< constructor-arg ref =dataSource/>
< / bean>

<! - 这是用于访问JdbcTokenStore
类的函数的服务类。这就像MVC结构JdbcTokenStore是Dao层和DefaultTokenServices
是服务层 - >
< bean id =tokenServices
class =org.springframework.security.oauth2.provider.token.DefaultTokenServices>
< property name =tokenStoreref =tokenStore/>
< property name =supportRefreshTokenvalue =true/>
< property name =clientDetailsS​​erviceref =clientDetails/>
< / bean>

<! - 通过咨询
现有令牌来记住审批决定的用户审批处理程序 - >
< bean id =oAuth2RequestFactory
class =org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory>
< constructor-arg ref =clientDetails/>
< / bean>
< bean id =userApprovalHandler
class =org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler>
< property name =requestFactoryref =oAuth2RequestFactory/>
< property name =tokenStoreref =tokenStore/>
< / bean>

<! - 授权服务器配置服务器用于提供
客户端详细信息服务和令牌服务的实现,并启用
或禁用机制的某些方面全球。 - >
< oauth:authorization-server
client-details-service-ref =clientDetailstoken-services-ref =tokenServices
user-approval-handler-ref =userApprovalHandler >
< oauth:authorization-code />
< oauth:implicit />
< oauth:refresh-token />
< oauth:客户端凭证/>
< oauth:password authentication-manager-ref =authenticationManager/>
< / oauth:authorization-server>

<! - 资源服务器提供受OAuth2
令牌保护的资源。 Spring OAuth提供了一个Spring Security认证过滤器,
实现了此保护。 - >
< oauth:resource-server id =resourceServerFilter
token-services-ref =tokenServicesresource-id =rsourceId/>

<! - 如果只接受授予(或弃权)投票,则授予访问权限。我们可以
使用JSR-250注释来保护REST资源方法,如@RolesAllowed - >
< bean id =accessDecisionManagerclass =org.springframework.security.access.vote.UnanimousBased>
< property name =decisionVoters>
< list>
< bean class =org.springframework.security.access.annotation.Jsr250Voter/>
< / list>
< / property>
< / bean>

<! - 如果身份验证失败,并且调用者已要求特定内容
类型响应,则该入口点可以发送一个以及标准401状态 - >
< bean id =clientAuthenticationEntryPoint
class =org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint>
< property name =realmNamevalue =empirecl-api / client/>
< property name =typeNamevalue =Basic/>
< / bean>

< bean id =oauthAuthenticationEntryPoint
class =org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint>
< property name =realmNamevalue =empirecl-api/>
< / bean>

< bean id =oauthAccessDeniedHandler
class =org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler/>

<! - 如果包含
作为安全过滤器,则允许客户端使用请求参数进行身份验证。该规范建议您允许
客户端的HTTP基本认证,而不使用此过滤器。 - >
< bean id =clientCredentialsTokenEndpointFilter
class =org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter>
< property name =authenticationManagerref =authenticationManager/>
< / bean>

< sec:http pattern =/ oauth / tokencreate-session =stateless
authentication-manager-ref =authenticationManager>
< sec:intercept-url pattern =/ oauth / tokenaccess =IS_AUTHENTICATED_FULLY/>
< sec:intercept-url pattern =/ api / logoutaccess =ROLE_USER,ROLE_ADMINmethod =GET/>
< sec:logout invalidate-session =truelogout-url =/ api / logout/>

< sec:anonymous enabled =false/>
< sec:http-basic entry-point-ref =clientAuthenticationEntryPoint/>
< sec:custom-filter ref =clientCredentialsTokenEndpointFilter
before =BASIC_AUTH_FILTER/>
< sec:access-denied-handler ref =oauthAccessDeniedHandler/>
< / sec:http>
< / beans>

以下是我的 web.xml 文件:

 <?xml version =1.0encoding =UTF-8?> 

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd
version =3.0>

 < context-param> 
< param-name> ; contextConfigLocation< / param-name>
< param-value>
classpath:security-config / spring-security-oauth2.xml
classpath *:** / applicationContext * .xml
< / param-value>
< / context-param>

< listener>
< listener-class> org.springframework.web.context .ContextLoaderListener< / listener-class>
< / listener>


< servlet>
< servlet-name> empirecl< / servlet-name>
< servlet-class> org.springframework.web.servlet.DispatcherServlet< / servlet-class>
< load-on-startup> 1< / load-on-startup>
< / servlet>
< servlet-mapping>
< servlet-name> empirecl< / servlet-name>
< url-pattern> /< / url-pattern的>
< / servlet-mapping>

< filter>
< filter-name> springSecurityFilterChain< / filter-name>
< filter-class> org.springframework.web.filter.DelegatingFilterProxy< / filter-class>
< init-param>
< param-name> contextAttribute< / param-name>
< param-value> org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring< / param-value>
< / init-param>
< / filter>
< filter-mapping>
< filter-name> springSecurityFilterChain< / filter-name>
< url-pattern> / *< / url-pattern>
< / filter-mapping>



当我启动服务器时,应用程序成功加载,并且没有异常抛出。但是,当我尝试使用Postman chrome休息客户端打到URL时,将抛出以下异常:

  SEVERE:Servlet.service )for servlet [empirecl]在与路径[/ empirecl-api]的上下文中抛出异常
java.lang.IllegalStateException:没有找到WebApplicationContext:没有注册ContextLoaderListener?
在org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:252)
在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
在org.apache .catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
在org.apache.catalina.core .StandardHostValve.invoke(StandardHostValve.java:136)
在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:78)
在org.apache.catalina.valves.AbstractAccessLogValve.invoke (AbstractAccessLogValve.java:610)
在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
在org.apache.catalina.connector.CoyoteAdapter.servi ce(CoyoteAdapter.java:526)
在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1033)
在org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol。 java:652)
在org.apache.coyote.http11.Http11NioProtocol $ Http11ConnectionHandler.process(Http11NioProtocol.java:222)
在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun( NioEndpoint.java:1566)
在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java:1523)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor。 java:1142)
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread。 java:61)
在java.lang.Thread.run(Thread.java:745)

在我的应用程序配置Oauth2之前,其余的服务工作成功,没有异常被抛出,但是呃配置,当我试图打url访问oauth令牌,它将抛出异常。按照我的网址:

  http:// localhost:8080 / empirecl-api / oauth / token 

提前感谢,我是Oauth和Spring-Security的新成员。确切的问题是什么?

解决方案

我发现解决方案需要删除< init-param> ; 来自 DelegatingFilterProxy 。之后应用程序将运行。我认为 security-filter 覆盖 contextAttribute org.springframework.web.servlet.FrameworkServlet容器中找不到.CONTEXT.spring 值。


I am using Oauth2 with spring-security for secure my rest services. i am using latest version of oauth2 and spring-security dependencies. Following is my dependencies:

<!-- Spring Security Dependencies -->
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.security.oauth</groupId>
    <artifactId>spring-security-oauth2</artifactId>
</dependency>
<!-- END of Core Spring and Spring Web Dependencies -->

I am using maven multimodule project. so the version of dependencies in declare in parent pom. Following are the versions of depdendencies:

<spring-security-oauth2>2.0.1.RELEASE</spring-security-oauth2>
<spring.security.version>3.2.4.RELEASE</spring.security.version>

My Spring-security-aouth2.xml configuration file as follow:

<?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:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="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
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">

<!-- Create client details bean for manage client details from database -->
<!-- The JdbcClientDetailsService provide default implementation for fetching 
    the data from oauth_client_details table Other wise we need to create our 
    custom class that Implement ClientDetailsService Interface and override its 
    loadClientByClientId method -->
<bean id="clientDetails"
    class="org.springframework.security.oauth2.provider.client.JdbcClientDetailsService">
    <constructor-arg index="0">
        <ref bean="dataSource" />
    </constructor-arg>
</bean>

<!-- Configure Authentication manager -->
<bean id="passwordEncoder"
    class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
    <constructor-arg name="strength" value="11" />
</bean>

<!-- This class is the custom implementation of UserDetailSerive Interface 
    that provide by the spring, which we Need to implement and override its method. 
    But for Oauth spring provide us ClientDetailsUserDetailsService, which already 
    implement UserDetailSerive Interface and override its method. -->
<bean id="clientDetailsUserService"
    class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService">
    <constructor-arg ref="clientDetails" />
    <property name="passwordEncoder" ref="passwordEncoder"></property>
</bean>

<!-- <bean id="oauthDaoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"> 
    <property name="passwordEncoder" ref="passwordEncoder" /> <property name="userDetailsService" 
    ref="clientDetailsUserService" /> </bean> -->

<sec:authentication-manager id="authenticationManager">
    <sec:authentication-provider
        user-service-ref="clientDetailsUserService" />
</sec:authentication-manager>

<!-- Oauth Token Service Using Database -->
<!-- The JdbcTokenStore class provide the default implementation from access 
    the token from database. If we want to customize the JDBC implementation 
    we need to implement TokenStore interface and overrider its methods -->
<bean id="tokenStore"
    class="org.springframework.security.oauth2.provider.token.store.JdbcTokenStore">
    <constructor-arg ref="dataSource" />
</bean>

<!-- This the service class which is used to access the function of JdbcTokenStore 
    class. This is like MVC structure JdbcTokenStore is Dao layer and DefaultTokenServices 
    is service layer -->
<bean id="tokenServices"
    class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
    <property name="tokenStore" ref="tokenStore" />
    <property name="supportRefreshToken" value="true" />
    <property name="clientDetailsService" ref="clientDetails" />
</bean>

<!-- A user approval handler that remembers approval decisions by consulting 
    existing tokens -->
<bean id="oAuth2RequestFactory"
    class="org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory">
    <constructor-arg ref="clientDetails" />
</bean>
<bean id="userApprovalHandler"
    class="org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler">
    <property name="requestFactory" ref="oAuth2RequestFactory" />
    <property name="tokenStore" ref="tokenStore" />
</bean>

<!-- Authorization Server Configuration of the server is used to provide 
    implementations of the client details service and token services and to enable 
    or disable certain aspects of the mechanism globally. -->
<oauth:authorization-server
    client-details-service-ref="clientDetails" token-services-ref="tokenServices"
    user-approval-handler-ref="userApprovalHandler">
    <oauth:authorization-code />
    <oauth:implicit />
    <oauth:refresh-token />
    <oauth:client-credentials />
    <oauth:password authentication-manager-ref="authenticationManager" />
</oauth:authorization-server>

<!-- A Resource Server serves resources that are protected by the OAuth2 
    token. Spring OAuth provides a Spring Security authentication filter that 
    implements this protection. -->
<oauth:resource-server id="resourceServerFilter"
    token-services-ref="tokenServices" resource-id="rsourceId" />

<!-- Grants access if only grant (or abstain) votes were received. We can 
    protect REST resource methods with JSR-250 annotations such as @RolesAllowed -->
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased">
    <property name="decisionVoters">
        <list>
            <bean class="org.springframework.security.access.annotation.Jsr250Voter" />
        </list>
    </property>
</bean>

<!-- If authentication fails and the caller has asked for a specific content 
    type response, this entry point can send one, along with a standard 401 status -->
<bean id="clientAuthenticationEntryPoint"
    class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
    <property name="realmName" value="empirecl-api/client" />
    <property name="typeName" value="Basic" />
</bean>

<bean id="oauthAuthenticationEntryPoint"
    class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
    <property name="realmName" value="empirecl-api" />
</bean>

<bean id="oauthAccessDeniedHandler"
    class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler" />

<!-- Allows clients to authenticate using request parameters if included 
    as a security filter. It is recommended by the specification that you permit 
    HTTP basic authentication for clients, and not use this filter at all. -->
<bean id="clientCredentialsTokenEndpointFilter"
    class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter">
    <property name="authenticationManager" ref="authenticationManager" />
</bean>

<sec:http pattern="/oauth/token" create-session="stateless"
    authentication-manager-ref="authenticationManager">
    <sec:intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
    <sec:intercept-url pattern="/api/logout" access="ROLE_USER,ROLE_ADMIN" method="GET" />
    <sec:logout invalidate-session="true" logout-url="/api/logout" />

    <sec:anonymous enabled="false" />
    <sec:http-basic entry-point-ref="clientAuthenticationEntryPoint" />
    <sec:custom-filter ref="clientCredentialsTokenEndpointFilter"
        before="BASIC_AUTH_FILTER" />
    <sec:access-denied-handler ref="oauthAccessDeniedHandler" />
</sec:http>
</beans>

Following is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
                classpath:security-config/spring-security-oauth2.xml
                classpath*:**/applicationContext*.xml
    </param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>


<servlet>
    <servlet-name>empirecl</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>empirecl</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>    
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
        <param-name>contextAttribute</param-name>
        <param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

When i start the server, the application successfully loaded and there is no exception throw. But when i try to hit the URL using Postman chrome rest client, the follwoing exception will thrown:

SEVERE: Servlet.service() for servlet [empirecl] in context with path [/empirecl-api] threw exception
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:252)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:78)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1033)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

Before configure the Oauth2 with my application, the rest service work successfully and there is no exception was thrown, but after configuration, when i am trying to hit the url for access Oauth token, it will thrown an exception. Following my my url:

http://localhost:8080/empirecl-api/oauth/token

Thanks in advance, I am new in Oauth and Spring-Security. what the exact problem is ?

解决方案

I found the solution, need to remove <init-param> from DelegatingFilterProxy. After that application will run. I think security-filter override the contextAttribute and org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring value not found by the container.

这篇关于Oauth2和Spring-Security:java.lang.IllegalStateException:没有找到WebApplicationContext:没有注册ContextLoaderListener?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆