2016-07-31 89 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