2016-07-31 170 views
0

背景:我有一个Web应用程序,它利用AngularJS,spring-mvc和spring-rest来提供UI。我有一个要求使用Elastic LB进行负载平衡,并且它使用粘性会话是而不是;请求是循环法。我使用gemfire的spring-session实现了会话复制,用于会话存储。这很好。混合spring-security-gemfire和spring-security-oauth2时节省会话

我需要与OAuth2身份验证服务器(最终多个OAuth2服务器)集成,纯粹用于身份验证和userInfo的传递。我试图在网络应用上使用spring cloud oauth2 @ EnableOAuth2Sso,并遇到一些会话序列化问题。在会话保存期间,仅将oauth2ClientContext添加到会话似乎会导致ClassCastException问题。

我试图拉下下面的例子,他们开箱即用,尤其是UI和Authserver。
https://github.com/spring-guides/tut-spring-security-and-angular-js

但是,当我在混合中添加春季会话时,试图序列化到gemfire服务器,我遇到了完全相同的问题。

这里是堆栈跟踪亮点:

java.lang.ClassCastException: cannot assign instance of org.springframework.beans.factory.support.StaticListableBeanFactory to field org.springframework.aop.scope.DefaultScopedObject.beanFactory of type org.springframework.beans.factory.config.ConfigurableBeanFactory in instance of org.springframework.aop.scope.DefaultScopedObject

以下简称堆栈跟踪:

ERROR o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception 

org.springframework.dao.DataAccessResourceFailureException: remote server on machine(gemfire:21800:loner):57660:9d1f3438:gemfire: : While performing a remote put; nested exception is com.gemstone.gemfire.cache.client.ServerOperationException: remote server on machine(gemfire:21800:loner):57660:9d1f3438:gemfire: : While performing a remote put 
    at org.springframework.data.gemfire.GemfireCacheUtils.convertGemfireAccessException(GemfireCacheUtils.java:238) ~[spring-data-gemfire-1.7.4.RELEASE.jar:1.7.4.RELEASE] 
    at org.springframework.data.gemfire.GemfireAccessor.convertGemFireAccessException(GemfireAccessor.java:91) ~[spring-data-gemfire-1.7.4.RELEASE.jar:1.7.4.RELEASE] 
    at org.springframework.data.gemfire.GemfireTemplate.put(GemfireTemplate.java:190) ~[spring-data-gemfire-1.7.4.RELEASE.jar:1.7.4.RELEASE] 
    at org.springframework.session.data.gemfire.GemFireOperationsSessionRepository.save(GemFireOperationsSessionRepository.java:147) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at org.springframework.session.data.gemfire.GemFireOperationsSessionRepository.save(GemFireOperationsSessionRepository.java:35) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.commitSession(SessionRepositoryFilter.java:244) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.access$100(SessionRepositoryFilter.java:214) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:167) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) ~[spring-session-1.2.1.RELEASE.jar:na] 
    ... tomcat filter chain and spring filter stuff 
Caused by: com.gemstone.gemfire.cache.client.ServerOperationException: remote server on machine(gemfire:21800:loner):57660:9d1f3438:gemfire: : While performing a remote put 
    ... gemfire internal stuff 
    at org.springframework.data.gemfire.GemfireTemplate.put(GemfireTemplate.java:187) ~[spring-data-gemfire-1.7.4.RELEASE.jar:1.7.4.RELEASE] 
    ... 31 common frames omitted 
Caused by: java.lang.ClassCastException: cannot assign instance of org.springframework.beans.factory.support.StaticListableBeanFactory to field org.springframework.aop.scope.DefaultScopedObject.beanFactory of type org.springframework.beans.factory.config.ConfigurableBeanFactory in instance of org.springframework.aop.scope.DefaultScopedObject 
    at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2133) ~[na:1.7.0_80] 
    at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1305) ~[na:1.7.0_80] 
    ... java.io stuff 
    at org.springframework.aop.framework.AdvisedSupport.readObject(AdvisedSupport.java:557) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE] 
    at sun.reflect.GeneratedMethodAccessor224.invoke(Unknown Source) ~[na:na] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80] 
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.7.0_80] 
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058) ~[na:1.7.0_80] 
    ... java.io stuff 
    at com.gemstone.gemfire.internal.InternalDataSerializer.basicReadObject(InternalDataSerializer.java:2966) ~[gemfire-8.1.0.jar:na] 
    at com.gemstone.gemfire.DataSerializer.readObject(DataSerializer.java:3210) ~[gemfire-8.1.0.jar:na] 
    at org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository$GemFireSessionAttributes.readObject(AbstractGemFireOperationsSessionRepository.java:800) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository$GemFireSessionAttributes.fromDelta(AbstractGemFireOperationsSessionRepository.java:834) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository$GemFireSession.fromDelta(AbstractGemFireOperationsSessionRepository.java:589) ~[spring-session-1.2.1.RELEASE.jar:na] 
    at com.gemstone.gemfire.internal.cache.EntryEventImpl.processDeltaBytes(EntryEventImpl.java:1345) ~[gemfire-8.1.0.jar:na] 
    ... gemfire internal stuff 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.7.0_80] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.7.0_80] 
    at com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl$1$1.run(AcceptorImpl.java:577) ~[gemfire-8.1.0.jar:na] 
    ... 1 common frames omitted 

我发现下面,https://jira.spring.io/browse/SPR-14117,鼓励我去更新一些的罐子到最新版本,希望春季启动版本只是在后面,但它似乎没有帮助。

版本信息:

spring-cloud-starter-parent: Brixton.SR4 spring-cloud-security: 1.1.2.RELEASE spring-core: 4.3.2.RELEASE spring-security-oauth2: 2.0.10.RELEASE spring-session: 1.2.1.RELEASE

我已经考虑了几个选择:重新布线的OAuth2框架不再使用ScopedProxyMode.INTERFACES(似乎令人生畏),使用Redis的主场迎战的GemFire,写整个客户端从头开始(我之前做过...不好玩)。

FWIW我已经添加了RequestContextFilter两个建议位置:OAuth2ClientContext (spring-security-oauth2) not persisted in Redis when using spring-session and spring-cloud-security

没有人有任何指导?

回答

0

我不知道这是否直接说出你的问题,但是我有/有类似的问题,我想我有和你一样的所有版本。似乎有很多Spring项目,他们都试图跟上彼此,所以有时似乎存在兼容性问题。我发现Rob Winch在这里列出的步骤修复了我的问题 - https://github.com/spring-projects/spring-session/issues/395

+0

是的,我尝试了引导应用程序和云应用程序的部分。没有帮助。最终,由于时间限制,我放弃了宝石之火,并使用redis。现在我有99个redis问题,而且宝石不是其中之一。 – qkerby

+0

我接受了你的回答,因为......当你没有其他人的时候你出现了,因为你完全是主题。 – qkerby