[英]Redisson for JCache Session persistence on WebSphere-Liberty: how to pass redisson-jcache.yaml?
您好 Open Liberty 專家,
作為一項研發工作,我正在嘗試通過 JCache/Redisson 啟用由 Redis 支持的 Liberty session 持久性。 我觀察到 CLASSPATH 似乎通過<library>
和<httpSessionCache libraryRef>
語法正確配置,但配置文件沒有被傳遞給org.redisson.jcache.JCacheManager.createCache()
。 該方法是javax.cache.CacheManager.createCache()的一個實現
這是我的服務器。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 方法的進入/退出等。
跟蹤 output 應出現在您的服務器 output 文件夾下的 /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 是正確的。 修復后一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.