Cannot Seem To Get Custom REST Deployment To Register Properly

Hi all… I’m trying to add a custom REST resource to my KeyCloak 9.0.3 server. I can see in the logs that when I copy the JAR to <keycloak>/standalone/deployments/ that JBoss/Wildfly sees the JAR and loads it, but none of the logging statements in my Provider, Factory, or Resource classes ever output anything in the logs. My example code is here: https://github.com/redhat-appdev-practice/keycloak-custom-rest

The logs look like:

keycloak_1    | 03:25:59,844 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 2) WFLYDR0001: Content added at location /deployment/standalone/data/content/8b/1ab01e469e114acb5290b4661de38a42e010a1/content
keycloak_1    | 03:25:59,849 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0028: Stopped deployment hello-rest-example.jar (runtime-name: hello-rest-example.jar) in 3ms
keycloak_1    | 03:25:59,850 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "hello-rest-example.jar" (runtime-name: "hello-rest-example.jar")
keycloak_1    | 03:25:59,892 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0016: Replaced deployment "hello-rest-example.jar" with deployment "hello-rest-example.jar"
keycloak_1    | 03:25:59,892 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 2) WFLYDR0002: Content removed from location /deployment/standalone/data/content/09/657cfd004489e8798a371bdfe4782ae9ffd878/content

If anyone could suggest some way of figuring this out I would greatly appreciate it.

FYI, the keycloak server is using the Docker container and an external PostgreSQL database. My compose file is as follows:

version: '3.1'
services:
  postgresql:
    image: 'postgres:latest'
    ports:
      - '5432:5432'
    environment:
      - POSTGRES_USER=keycloak
      - POSTGRES_PASSWORD=keycloak
      - POSTGRES_DATABASE=keycloak
    volumes:
    - '/home/dphillips/tmp/fmc_pg_keycloak:/var/lib/postgresql/data'
  keycloak:
    image: jboss/keycloak:9.0.3
    # volumes:
    # - "./:/deployment/"
    ports:
    - '8080:8080'
    - '9990:9990'
    - '8787:8787'
    links:
    - postgresql
    # working_dir: /deployment
    # command:
    # - ./bin/standalone.sh
    # - '-Djboss.bind.address=0.0.0.0'
    # - '-Djboss.bind.address.private=0.0.0.0'
    # - '-Djboss.bind.address.management=0.0.0.0'
    environment:
      DB_VENDOR: postgres
      DB_ADDR: postgresql:5432
      DB_DATABASE: keycloak
      DB_USER: keycloak
      DB_PASSWORD: keycloak
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: 2wsx3edc

Good news… I answered my own problem and there was really only a single issue I was experiencing… The location of the resource reference file **org.keycloak.services.resource.RealmResourceProviderFactory** in my initial attempt was wrong… The file MUST be in src/main/resources/META-INF/services/ and I had it directly in the META-INF directory and as such it was never detected and loaded. I have updated my proof-of-concept project on GitHub to reflect a working implementation:

I hope this helps someone else!