redisson icon indicating copy to clipboard operation
redisson copied to clipboard

OpenLiberty httpSessionCache configuration server.xml

Open mxcd opened this issue 1 year ago • 3 comments

I am trying to use redisson as jCache implementation for the httpSessionCache of my open liberty server.
So far, I've managed to use the library by providing a configuration yaml file like so:

<!-- server.xml -->
<library id="jCacheVendorLib">
    <fileset dir="${shared.resource.dir}" includes="*"/>
    <folder dir="${shared.resource.dir}" />
  </library>
<httpSessionCache libraryRef="jCacheVendorLib" uri="file:${server.config.dir}/redis-config.yaml" />

My goal is to provide the redis uri and password using environment variables. The open liberty docs state, that I should be able to provide a "list of vendor-specific JCache configuration properties, which are passed to the JCache provider when the CacheManager is obtained" (see here )
My naive approach was to provide those properties with the same keys as I would in the yaml file:

<!-- server.xml -->
  <variable name="redis.uri" defaultValue="redis://localhost:6379"/>
  <variable name="redis.password" defaultValue=""/>

  <library id="jCacheVendorLib">
    <fileset dir="${shared.resource.dir}" includes="*"/>
    <folder dir="${shared.resource.dir}" />
  </library>

  <httpSessionCache libraryRef="jCacheVendorLib">
    <properties singleServerConfig.address="${redis.uri}"/>
    <properties singleServerConfig.password="${redis.password}"/>
  </httpSessionCache>

This unfortunately failed with

[INFO] [ERROR   ] SESN0307E: An exception occurred when initializing the cache. The exception is: java.lang.IllegalStateException: Default configuration hasn't been specified!
[INFO] 	at org.redisson.jcache.JCacheManager.createCache(JCacheManager.java:119)
[INFO] 	at com.ibm.ws.session.store.cache.CacheHashMap.cacheInit(CacheHashMap.java:192)
[INFO] 	at [internal classes]

Is this approach feasible or is there another way of achieving an environment variable based configuration?
Is there some piece of documentation specifying the "vendor-specific JCache configuration properties"?

Thanks a lot
Max

mxcd avatar Apr 25 '24 12:04 mxcd

Can you use env variables instead described in "Environmental variables" section ? https://github.com/redisson/redisson/wiki/2.-Configuration#221-yaml-file-based-configuration

mrniko avatar Apr 28 '24 06:04 mrniko

Hi @mrniko
Indeed directly stating the env variables in the YAML configuration file worked. It didn't occur to me since I was focused on using the open liberty server.xml variables.
Thanks for the support

mxcd avatar Apr 29 '24 09:04 mxcd

Hi,

I considered this issue as a feature request.

mrniko avatar Apr 29 '24 10:04 mrniko