使用远程 Infinispan 缓存运行 Keycloak 时发生 ClassCastExceptions

问题描述 投票:0回答:1

设置

Keycloak 16.1.1 连接到 Infinispan 14 集群,用于远程缓存会话数据(用户会话、身份验证会话、客户端会话等)。 Keycloak 和 Infinispan 都使用 OpenJDK 11。

Keycloak远程缓存初始化如下:

echo *** Setup Infinispan cache module ***
/subsystem=infinispan/cache-container=keycloak:write-attribute(name=module, value=org.keycloak.keycloak-model-infinispan)

echo *** Add remote socket binding to Infinispan cluster ***
/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=remote-cache:add(host=${remote.cache.host:localhost}, port=${remote.cache.port:11222})

echo ** Set work cache as remote store **
/subsystem=infinispan/cache-container=keycloak/replicated-cache=work/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/replicated-cache=work:write-attribute(name=statistics-enabled,value=true)

echo ** Set sessions cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions:write-attribute(name=statistics-enabled,value=true)

echo ** Set authenticationSessions cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions:write-attribute(name=statistics-enabled,value=true)

echo ** Set offlineSessions cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions:write-attribute(name=statistics-enabled,value=true)

echo ** Set clientSessions cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=clientSessions/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/distributed-cache=clientSessions:write-attribute(name=statistics-enabled,value=true)

echo ** Set offlineClientSessions cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions:write-attribute(name=statistics-enabled,value=true)

echo ** Set loginFailure cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures:write-attribute(name=statistics-enabled,value=true)

echo ** Set actionTokens cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=actionTokens/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)
/subsystem=infinispan/cache-container=keycloak/distributed-cache=actionTokens:write-attribute(name=statistics-enabled,value=true)

echo *** Setting CACHE_OWNERS to "${env.CACHE_OWNERS}" in all cache-containers ***
/subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions:write-attribute(name=owners, value=${env.CACHE_OWNERS:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions:write-attribute(name=owners, value=${env.CACHE_OWNERS:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions:write-attribute(name=owners, value=${env.CACHE_OWNERS:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=clientSessions:write-attribute(name=owners, value=${env.CACHE_OWNERS:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions:write-attribute(name=owners, value=${env.CACHE_OWNERS:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures:write-attribute(name=owners, value=${env.CACHE_OWNERS:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=actionTokens:write-attribute(name=owners, value=${env.CACHE_OWNERS:1})

Infinispan 集群配置是:

   <cache-container name="default" statistics="true">
      <transport cluster="${infinispan.cluster.name:default-ispan-cluster}" node-name="${infinispan.node.name:env.HOST}" stack="nxt-stack"/>
      <serialization marshaller="org.infinispan.jboss.marshalling.commons.GenericJBossMarshaller">
         <allow-list>
            <regex>org.keycloak.*</regex>
            <regex>java.util.*</regex>
         </allow-list>
      </serialization>
      <replicated-cache-configuration name="sessions-cfg" start="EAGER">
         <transaction mode="NON_XA" locking="PESSIMISTIC"/>
      </replicated-cache-configuration>
      <replicated-cache name="work" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
      <replicated-cache name="sessions" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
      <replicated-cache name="authenticationSessions" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
      <replicated-cache name="offlineSessions" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
      <replicated-cache name="clientSessions" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
      <replicated-cache name="offlineClientSessions" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
      <replicated-cache name="actionTokens" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
      <replicated-cache name="loginFailures" configuration="sessions-cfg">
         <encoding media-type="application/x-jboss-marshalling"/>
      </replicated-cache>
   </cache-container>

问题

我可以确认一些缓存数据存储在Infinispan中(即actionTokens)。

但是,对于大多数缓存检索(包括用户会话),我在 Keycloak 端遇到 ClassCastExceptions,所有这些都引用了无法转换为 SessionEntityWrapper

您只需在 Keycloak 管理控制台上查看用户会话或尝试登录即可轻松重现以下错误。 (尝试转换为

RootAuthenticationSessionEntity
时也会发生这种情况)

07:29:36,571 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-2) Uncaught server error: com.fasterxml.jackson.databind.JsonMappingException: java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper (java.lang.Boolean is in module java.base of loader 'bootstrap'; org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper is in unnamed module of loader '[email protected]' @70e80e4f)
    at [email protected]//com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._wrapAsIOE(DefaultSerializerProvider.java:509)
    at [email protected]//com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:482)
    at [email protected]//com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:400)
    at [email protected]//com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1510)
    at [email protected]//com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1006)
    at [email protected]//org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.writeTo(ResteasyJackson2Provider.java:345)
    at [email protected]//org.jboss.resteasy.core.messagebody.AsyncBufferedMessageBodyWriter.asyncWriteTo(AsyncBufferedMessageBodyWriter.java:24)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:87)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.asyncProceed(AbstractWriterInterceptorContext.java:203)
    at [email protected]//org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.asyncAroundWriteTo(DigitalSigningInterceptor.java:169)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.asyncProceed(AbstractWriterInterceptorContext.java:211)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.getStarted(AbstractWriterInterceptorContext.java:166)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.lambda$getStarted$0(ServerWriterInterceptorContext.java:73)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.aroundWriteTo(ServerWriterInterceptorContext.java:93)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.getStarted(ServerWriterInterceptorContext.java:73)
    at [email protected]//org.jboss.resteasy.core.ServerResponseWriter.lambda$writeNomapResponse$3(ServerResponseWriter.java:163)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:404)
    at [email protected]//org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:252)
    at [email protected]//org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:101)
    at [email protected]//org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:74)
    at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:594)
    at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
    at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
    at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
    at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
    at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
    at [email protected]//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
    at [email protected]//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:60)
    at [email protected]//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
    at [email protected]//javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
    at [email protected]//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
    at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
    at [email protected]//org.keycloak.provider.wildfly.WildFlyRequestFilter.lambda$doFilter$0(WildFlyRequestFilter.java:41)
    at [email protected]//org.keycloak.services.filters.AbstractRequestFilter.filter(AbstractRequestFilter.java:43)
    at [email protected]//org.keycloak.provider.wildfly.WildFlyRequestFilter.doFilter(WildFlyRequestFilter.java:39)
    at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at [email protected]//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
    at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.lambda$handleRequest$1(ElytronRunAsHandler.java:68)
    at [email protected]//org.wildfly.security.auth.server.FlexibleIdentityAssociation.runAsFunctionEx(FlexibleIdentityAssociation.java:103)
    at [email protected]//org.wildfly.security.auth.server.Scoped.runAsFunctionEx(Scoped.java:161)
    at [email protected]//org.wildfly.security.auth.server.Scoped.runAs(Scoped.java:73)
    at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.handleRequest(ElytronRunAsHandler.java:67)
    at [email protected]//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
    at [email protected]//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117)
    at [email protected]//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at [email protected]//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at [email protected]//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at org.wildfly.security.elytron-web.undertow-server-servlet@1.10.1.Final//org.wildfly.elytron.web.undertow.server.servlet.CleanUpHandler.handleRequest(CleanUpHandler.java:38)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
    at [email protected]//io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:275)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:79)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:134)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:131)
    at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:255)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:79)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:100)
    at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
    at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:852)
    at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
    at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
    at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.infinispan.commons.CacheException: java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper (java.lang.Boolean is in module java.base of loader 'bootstrap'; org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper is in unnamed module of loader '[email protected]' @70e80e4f)
    at [email protected]//org.infinispan.commons.util.Util.rewrapAsCacheException(Util.java:686)
    at [email protected]//org.infinispan.commons.reactive.RxJavaInterop.lambda$static$2(RxJavaInterop.java:47)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableOnErrorNext$OnErrorNextSubscriber.onError(FlowableOnErrorNext.java:94)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableRepeatUntil$RepeatSubscriber.onError(FlowableRepeatUntil.java:72)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableDoOnLifecycle$SubscriptionLambdaSubscriber.onError(FlowableDoOnLifecycle.java:86)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.processors.UnicastProcessor.checkTerminated(UnicastProcessor.java:415)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.processors.UnicastProcessor.drainRegular(UnicastProcessor.java:301)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.processors.UnicastProcessor.drain(UnicastProcessor.java:384)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.processors.UnicastProcessor.subscribeActual(UnicastProcessor.java:486)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15868)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableDoOnLifecycle.subscribeActual(FlowableDoOnLifecycle.java:39)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15868)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15814)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableScalarXMap$ScalarXMapFlowable.subscribeActual(FlowableScalarXMap.java:160)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15868)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15814)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableScalarXMap$ScalarXMapFlowable.subscribeActual(FlowableScalarXMap.java:160)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15868)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15814)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableRepeatUntil$RepeatSubscriber.subscribeNext(FlowableRepeatUntil.java:109)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableRepeatUntil.subscribeActual(FlowableRepeatUntil.java:38)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15868)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15814)
    at [email protected]//org.infinispan.reactive.publisher.impl.ClusterPublisherManagerImpl$SubscriberHandler.start(ClusterPublisherManagerImpl.java:983)
    at [email protected]//org.infinispan.reactive.publisher.impl.ClusterPublisherManagerImpl$AbstractSegmentAwarePublisher.subscribe(ClusterPublisherManagerImpl.java:1180)
    at [email protected]//org.infinispan.reactive.publisher.impl.SegmentCompletionPublisher.subscribe(SegmentCompletionPublisher.java:34)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15868)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.FlowableOnErrorNext.subscribeActual(FlowableOnErrorNext.java:39)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.core.Flowable.subscribe(Flowable.java:15868)
    at io.reactivex.rxjava3.rxjava//io.reactivex.rxjava3.internal.operators.flowable.BlockingFlowableIterable.iterator(BlockingFlowableIterable.java:42)
    at [email protected]//org.infinispan.commons.util.Closeables.iterator(Closeables.java:238)
    at [email protected]//org.infinispan.util.Closeables.iterator(Closeables.java:26)
    at [email protected]//org.infinispan.stream.impl.DistributedCacheStream.iterator(DistributedCacheStream.java:376)
    at [email protected]//org.infinispan.stream.impl.DistributedCacheStream.spliterator(DistributedCacheStream.java:449)
    at [email protected]//org.infinispan.util.AbstractDelegatingCacheStream.spliterator(AbstractDelegatingCacheStream.java:187)
    at [email protected]//org.keycloak.models.sessions.infinispan.InfinispanUserSessionProvider.getUserSessionsStream(InfinispanUserSessionProvider.java:373)
    at [email protected]//org.keycloak.models.sessions.infinispan.InfinispanUserSessionProvider.getUserSessionsStream(InfinispanUserSessionProvider.java:398)
    at [email protected]//org.keycloak.services.resources.admin.UserResource.getSessions(UserResource.java:358)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at [email protected]//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
    at [email protected]//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
    at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
    at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
    at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
    at org.jboss.resteasy.resteasy-
    ...

java caching keycloak classcastexception infinispan
1个回答
0
投票

看起来主要问题是

remote-store
配置为
cache=actionTokens
而不是正在配置的缓存名称:

echo ** Set offlineClientSessions cache as remote store **
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions/store=remote:add( \
    passivation=false, \
    fetch-state=false, \
    purge=false, \
    preload=false, \
    shared=true, \
    cache=actionTokens, \
    remote-servers=["remote-cache"], \
    properties={ \
        rawValues=true, \
        marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, \
        protocolVersion=${env.HOTROD_VERSION:2.8} \
    } \
)

注意“cache=actionTokens”行,但分布式缓存是“offlineClientSessions”

© www.soinside.com 2019 - 2024. All rights reserved.