How to setup the JAAS LoginModule on tomcat?

I want to use the JAAS DirectAccessGrantsLoginModule on an application, which runs on tomcat (Comsol Server).

Below is the config in the application and the auxilliary keycloak.json. There are some sample configs, which I followed, but in general the config for the particular LoginModule is governed by the module itself. So I followed the docs of the JAAS Plugin and this example. I had some difficulties to get the module recognized at all by the application / tomcat, but finally that worked. I inserted the keycloak-adapter-core 21.1.1 from jar-download com together with a bunch of dependencies in /bin/tomcat/lib/, so now the login module is found.

ComsolServerLogin {
    org.keycloak.adapters.jaas.DirectAccessGrantsLoginModule required 
    role-principal-class="org.keycloak.adapters.jaas.RolePrincipal"
    keycloak-config-file="/usr/local/comsol61/server/bin/tomcat/lib/keycloak.json";
    com.comsol.jaas.ComsolServiceLoginModule optional
    authenticate=true;
};

Here the keycloak.json:

{
  "realm" : "xxx",
  "resource" : "comsol",
  "auth-server-url" : "https://keycloak.xxx.xxx/auth",
  "ssl-required" : "all",

      "credentials": {
        "secret": "kGHv..."
    }
}

The error the application reports is

java.lang.NullPointerException

Any ideas where to start with troubleshooting? This is Keycloak 21.1.1.