Extending Keycloak with jar file without SPI

Hi all,

I’ve read how to extend Keycloak via SPI but it seems that there is no provider interface for my specific use case, as I am not looking to extend Keycloak but provide a custom method for Infinispan. I get the feeling that my jar, put into the standalone/deployments folder, is not loaded because it does not implement an SPI. I am looking for a way to make Keycloak load my custom jar file so I can reference my custom key 2 string mapper in in the following way:

      /subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions/store=jdbc:add(data-source="KeycloakDS", dialect="POSTGRES", fetch-state="true", passivation="true", preload="true", purge="false", shared="true", properties={"key2StringMapper" => "org.foo.keymappers.FooTwoWayKey2StringMapper"})

In order to use a database as a infinispan session cache store I need this custom key to string mapper that is able to transform a UUID to a string and vice versa to persist the sessions in a db table. Nothing fancy but it is not yet available in the Infinispan version used in Keycloak. This feature is available in the current Infinispan master branch though (https://github.com/infinispan/infinispan/pull/8736/files).

How does my jar file have to be constructed, especially the contents of the META-INF folder and where to place it ideally? Can I patch any of the modules.xml files to load it? I am fairly new to the java world, so I might be missing something simple here…

I tried loading it via the deployments folder, adding it as a module, even a global module…

    module add --name=org.pace --resources=/opt/jboss/keycloak/standalone/deployments/stringmapper.jar
    /subsystem=ee:list-add(name=global-modules, value={name=org.foo, slot=main})

Whatever I tried so far always resulted in

    12:39:34,610 ERROR [org.infinispan.persistence.jdbc.stringbased.JdbcStringBasedStore] (ServerService Thread Pool -- 65) Trying to instantiate org.foo.FooTwoWayKey2StringMapper, however it failed due to java.lang.ClassNotFoundException

Any help is appreciated!