如何解决WebSphere-Liberty 上的 Redisson for JCache 会话持久性:如何传递 redisson-jcache.yaml?
您好 Open Liberty 专家,
作为一项研发工作,我正在尝试启用由以下支持的 Liberty 会话持久性
Redis 通过 jcache/Redisson。我观察到 CLAsspATH 似乎是
通过 <library>
和 <httpSessionCache libraryRef>
语法正确配置,
但配置文件没有被传递
到org.redisson.jcache.jcacheManager.createCache()
。此方法是 javax.cache.CacheManager.createCache()
这是我的server.xml:
<?xml version="1.0" encoding="UTF-8"?>
<server description="defaultServer">
<!-- Enable features -->
<featureManager>
<feature>cdi-2.0</feature>
<feature>jaxb-2.2</feature>
<feature>jsf-2.3</feature>
<feature>jaxrs-2.1</feature>
<feature>ejbLite-3.2</feature>
<feature>sessionCache-1.0</feature>
</featureManager>
<!-- Define http & https endpoints -->
<httpEndpoint id="defaultHttpEndpoint" host="*"
httpPort="9080" httpsPort="9443" />
<library id="jcachevendorLib">
<fileset dir="${shared.resource.dir}" includes="*"/>
<folder dir="${shared.resource.dir}" />
</library>
<!-- trust JDK’s default truststore -->
<ssl id="defaultSSLConfig" trustDefaultCerts="true" />
<httpSessionCache libraryRef="jcachevendorLib"
uri="file:${shared.resource.dir}/redisson-jcache.yaml" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true" />
<!-- Define web application with its context root and location -->
<webApplication id="javaee-cafe" contextRoot="/"
location="${server.config.dir}/apps/javaee-cafe.war">
</webApplication>
</server>
无论我设置什么值
uri="file:${shared.resource.dir}/redisson-jcache.yaml"
我仍然得到
Liberty 启动时的此异常。
{
"host": "javaee-app-simple-cluster-85b47b866c-h5mk4","ibm_datetime": "2021-05-05T02:49:04.369+0000","ibm_messageId": "SESN0307E","ibm_sequence": "1620182944369_0000000000017","ibm_serverName": "defaultServer","ibm_threadId": "0000002a","ibm_userDir": "/opt/ol/wlp/usr/","loglevel": "ERROR","message": "SESN0307E: An exception occurred when initializing the cache. The exception is: java.lang.IllegalStateException: Default configuration hasn't been specified!
at org.redisson.jcache.jcacheManager.createCache(jcacheManager.java:118)
at com.ibm.ws.session.store.cache.CacheHashMap.cacheInit(CacheHashMap.java:182)
at com.ibm.ws.session.store.cache.CacheHashMap.lambda$new$0(CacheHashMap.java:134)
at com.ibm.ws.session.store.cache.CacheHashMap$$Lambda$90/0000000000000000.run(UnkNown Source)
at java.security.AccessController.doPrivileged(AccessController.java:678)
at com.ibm.ws.session.store.cache.CacheHashMap.<init>(CacheHashMap.java:133)
at com.ibm.ws.session.store.cache.CacheStore.<init>(CacheStore.java:33)
at com.ibm.ws.session.store.cache.CacheStoreService.createStore(CacheStoreService.java:316)
at com.ibm.ws.session.SessionContext.createStore(SessionContext.java:337)
at com.ibm.ws.session.SessionContext.createCoreSessionManager(SessionContext.java:254)
at com.ibm.ws.session.SessionContext.<init>(SessionContext.java:157)
at com.ibm.ws.webcontainer.session.impl.HttpSessionContextImpl.<init>(HttpSessionContextImpl.java:62)
at com.ibm.ws.webcontainer31.session.impl.HttpSessionContext31Impl.<init>(HttpSessionContext31Impl.java:37)
at com.ibm.ws.webcontainer31.session.impl.SessionContextRegistry31Impl.createSessionContextObject(SessionContextRegistry31Impl.java:40)
at com.ibm.ws.webcontainer.session.impl.SessionContextRegistryImpl.createSessionContext(SessionContextRegistryImpl.java:83)
at com.ibm.ws.webcontainer.session.impl.SessionContextRegistryImpl.getSessionContext(SessionContextRegistryImpl.java:304)
at com.ibm.ws.webcontainer.WebContainer.getSessionContext(WebContainer.java:699)
at com.ibm.ws.webcontainer.VirtualHost.getSessionContext(VirtualHost.java:188)
at com.ibm.ws.webcontainer.webapp.WebGroup.getSessionContext(WebGroup.java:156)
at com.ibm.ws.webcontainer.webapp.WebApp.createSessionContext(WebApp.java:1313)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationStart(WebApp.java:1296)
at com.ibm.ws.webcontainer.osgi.webapp.WebApp.commonInitializationStart(WebApp.java:254)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1014)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6683)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:470)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApplication(DynamicVirtualHost.java:465)
at com.ibm.ws.webcontainer.osgi.WebContainer.startWebApplication(WebContainer.java:1178)
at com.ibm.ws.webcontainer.osgi.WebContainer.access$100(WebContainer.java:109)
at com.ibm.ws.webcontainer.osgi.WebContainer$3.run(WebContainer.java:975)
at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:239)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:823).","module": "com.ibm.ws.session.store.cache.CacheHashMap","type": "liberty_message"
}
我尝试为
uri="file:${shared.resource.dir}/redisson-jcache.yaml"
而我仍然
得到相同的结果:IllegalStateException
如上所示。我是什么
我失踪了?
谢谢,
埃德
解决方法
查看 Open Liberty 源代码,看起来 uri 是在获取 CacheManager 时提供给 CachingProvider 的,
cacheManager = cachingProvider.getCacheManager(uri,null,vendorProperties);
查看代码在此处为 uri 提供的值会很有帮助,以确保它正确通过并且变量扩展正在工作并且没有损坏。为此,您可以打开以下跟踪:
<logging traceSpecification="*=info:com.ibm.ws.session.store.cache.*=all"/>
其中应该包括 JCache 方法的进入/退出等。
跟踪输出应显示在服务器输出文件夹下的 /logs/trace.log 中。
,可悲的是,这个问题的解决方案相当简单,解决问题更复杂。 redisson-jcache.yaml 文件中存在拼写错误。自从我知道 Ed 我们一直在谈论堆栈溢出,我们发现 redisson-jcache.yaml 文件包含以下内容:
clusterServerConfig:
password: ${clusterServerConfig.password}
nodeAddresses:
- ${clusterServerConfig.nodeAddresses}
事实证明它应该是:
clusterServersConfig:
password: ${clusterServerConfig.password}
nodeAddresses:
- ${clusterServerConfig.nodeAddresses}
注意正确的形式是 server 为复数。
所以出了什么问题,结果是如果 reddison yaml 文件由于任何原因没有解析它,它会继续进行,就好像没有提供配置一样,没有错误消息表明处理配置的问题是什么。然后它抛出一个神秘的异常,说没有提供配置。
将 printStackTrace 调用插入到 Redisson 代码库中的正确位置会产生一条有用的错误消息:
Unrecognized field "clusterServerConfig" (class org.redisson.config.Config),not marked as ignorable (23 known properties: "eventLoopGroup","maxCleanUpDelay","nettyHook","keepPubSubOrder","nettyThreads","threads","transportMode","singleServerConfig","sentinelServersConfig","reliableTopicWatchdogTimeout","useScriptCache","minCleanUpDelay","connectionListener","executor","codec","replicatedServersConfig","clusterServersConfig","useThreadClassLoader","masterSlaveServersConfig","addressResolverGroupFactory","lockWatchdogTimeout","cleanUpKeysAmount","referenceEnabled"])
所以这里的结论是绝对确保你的 redisson yaml 是正确的。确定一切正常。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。