WebSphere Liberty集成Redis实现HTTP会话持久化配置求助
WebSphere Liberty 集成 Redis 实现 HTTP 会话持久化(替换 WebSphere ExtremeScale)
我们计划在环境中替换 WebSphere ExtremeScale,改用 Redis 实现 HTTP 会话持久化(原 WebSphere ExtremeScale 仅用于此功能)。我们打算通过 JCache/Redisson 完成 WebSphere Liberty 与 Redis 的集成来实现会话持久化,恳请有相关经验的同行分享 redisson-jcache.yaml 及 server.xml 的配置。
当前启动时出现如下报错:
[3/27/24 1:04:12:216 UTC] 0000002b com.ibm.ws.logging.internal.impl.IncidentImpl I FFDC1015I: 已创建FFDC事件:"java.lang.IllegalStateException: 未指定默认配置! com.ibm.ws.session.store.cache.CacheHashMap 250",日志文件为ffdc_24.03.27_01.04.11.0.log [3/27/24 1:04:12:218 UTC] 0000002b com.ibm.ws.session.store.cache.CacheHashMap E SESN0307E: 初始化缓存时发生异常。 异常信息:java.lang.IllegalStateException: 未指定默认配置! at org.redisson.jcache.JCacheManager.createCache(JCacheManager.java:119) at com.ibm.ws.session.store.cache.CacheHashMap.cacheInit(CacheHashMap.java:192) at com.ibm.ws.session.store.cache.CacheHashMap.lambda$new$0(CacheHashMap.java:136) at java.security.AccessController.doPrivileged(AccessController.java:690) at com.ibm.ws.session.store.cache.CacheHashMap.<init>(CacheHashMap.java:135) at com.ibm.ws.session.store.cache.CacheStore.<init>(CacheStore.java:35) at com.ibm.ws.session.store.cache.CacheStoreService.createStore(CacheStoreService.java:323) at com.ibm.ws.session.SessionContext.createStore(SessionContext.java:355) at com.ibm.ws.session.SessionContext.createStore(SessionContext.java:344) at com.ibm.ws.session.SessionContext.createCoreSessionManager(SessionContext.java:257) at com.ibm.ws.session.SessionContext.createCoreSessionManager(SessionContext.java:190) at com.ibm.ws.webcontainer.session.impl.HttpSessionContextImpl.createCoreSessionManager(HttpSessionContextImpl.java:963) at com.ibm.ws.session.SessionContext.<init>(SessionContext.java:160) at com.ibm.ws.session.SessionContext.<init>(SessionContext.java:145) at com.ibm.ws.webcontainer.session.impl.HttpSessionContextImpl.<init>(HttpSessionContextImpl.java:61) at com.ibm.ws.webcontainer.session.impl.SessionContextRegistryImpl.createSessionContextObject(SessionContextRegistryImpl.java:98) at com.ibm.ws.webcontainer.session.impl.SessionContextRegistryImpl.createSessionContext(SessionContextRegistryImpl.java:86) at com.ibm.ws.webcontainer.session.impl.SessionContextRegistryImpl.getSessionContext(SessionContextRegistryImpl.java:309) at com.ibm.ws.webcontainer.WebContainer.getSessionContext(WebContainer.java:707) at com.ibm.ws.webcontainer.VirtualHost.getSessionContext(VirtualHost.java:190) at com.ibm.ws.webcontainer.webapp.WebGroup.getSessionContext(WebGroup.java:158) at com.ibm.ws.webcontainer.webapp.WebApp.createSessionContext(WebApp.java:1344) at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationStart(WebApp.java:1327) at com.ibm.ws.webcontainer.osgi.webapp.WebApp.commonInitializationStart(WebApp.java:256) at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1039) at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6705) at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:474) at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApplication(DynamicVirtualHost.java:469) at com.ibm.ws.webcontainer.osgi.WebContainer.startWebApplication(WebContainer.java:1197) at com.ibm.ws.webcontainer.osgi.WebContainer.access$100(WebContainer.java:112) at com.ibm.ws.webcontainer.osgi.WebContainer$3.run(WebContainer.java:994) at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:247) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522) at java.util.concurrent.FutureTask.run(FutureTask.java:277) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.lang.Thread.run(Thread.java:825)
配置示例
1. redisson-jcache.yaml 配置
将此文件放置在 Liberty 的 resources 目录下(或类路径可访问的位置):
# Redisson JCache 配置 config: singleServerConfig: address: "redis://localhost:6379" # 如果Redis有密码,取消注释下面一行 # password: "your-redis-password" database: 0 connectionPoolSize: 64 connectionMinimumIdleSize: 10 codec: !<org.redisson.codec.JsonJacksonCodec> {}
2. server.xml 配置
添加必要的特性和会话存储配置:
<!-- 启用JCache和会话缓存存储特性 --> <featureManager> <feature>servlet-4.0</feature> <!-- 根据你的应用版本调整 --> <feature>jcache-1.0</feature> <feature>sessionCache-1.0</feature> </featureManager> <!-- 配置Redisson JCache提供者 --> <cacheManager id="redissonJCache" jCacheLibraryRef="redissonLib"/> <library id="redissonLib"> <!-- 指向Redisson JCache相关的JAR包,确保路径正确 --> <fileset dir="${server.config.dir}/lib" includes="redisson-*.jar redisson-jcache-*.jar jackson-*.jar"/> </library> <!-- 配置HTTP会话使用Redis缓存存储 --> <httpSessionCache enableCache="true" cacheManagerRef="redissonJCache" cacheName="websphere-sessions"/> <!-- 可选:配置会话超时时间,单位秒 --> <httpSession timeout="1800"/>
报错说明
出现 IllegalStateException: 未指定默认配置! 是因为 Redisson JCache 无法找到默认配置文件。请确保:
redisson-jcache.yaml放置在类路径可访问的位置(如 Liberty 的resources目录或lib目录)- 如果自定义了配置文件路径,需要通过系统属性指定:
-Dredisson-jcache-config-path=/path/to/redisson-jcache.yaml
内容的提问来源于stack exchange,提问作者Rakesh Vohra
相关产品推荐
相关产品推荐

