adorsys / keycloak-config-cli

Import YAML/JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak.
Apache License 2.0
778 stars 140 forks source link

ERROR: java.lang.ClassNotFoundException: de.adorsys.keycloak.config.resource.ManagementPermissions #999

Open Clex1o1 opened 7 months ago

Clex1o1 commented 7 months ago

Current Behavior

After updating to Keycloak 23.0.a and updating the extensions version to the 5.10 (Keycloak 23.0.1) Keycloak is not starting properly and failed with the error: ERROR: java.lang.ClassNotFoundException: de.adorsys.keycloak.config.resource.ManagementPermissions

Expected Behavior

Clean start up 🙃

Steps To Reproduce

I'm using docker compose to run keycloak. My test setup looks like this:

version: "3"
services:
  keycloak:
    container_name: keycloak
    image: quay.io/keycloak/keycloak:23.0.1
    environment:
      KC_DB: mariadb
      KC_DB_URL_HOST: keycloak-db
      KC_DB_PASSWORD: root
      KC_DB_USERNAME: root
      KC_HOSTNAME: "localhost"
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: admin
    restart: unless-stopped
    depends_on:
      - keycloak-db
    volumes:
      - "./extensions/:/opt/keycloak/providers/"
    command:
      - start-dev
    ports:
      - "8081:8080"

  keycloak-db:
    restart: unless-stopped
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: "keycloak"

  adminer:
    image: adminer
    restart: unless-stopped
    ports:
      - 8080:8080

after docker-compose up it crashes with the error:

keycloak       | ERROR: Unexpected error when starting the server in (development) mode
keycloak       | ERROR: Failed to start quarkus
keycloak       | ERROR: java.lang.ClassNotFoundException: de.adorsys.keycloak.config.resource.ManagementPermissions
keycloak       | ERROR: de.adorsys.keycloak.config.resource.ManagementPermissions


### Environment

- Keycloak Version: 23.0.1
- keycloak-config-cli Version: 5.10
- Docker compose

### Anything else?

_No response_
jonasvoelcker commented 7 months ago

Hi @Clex1o1, version 23.0.1 is pretty old, may you try again with 23.0.7?

Clex1o1 commented 7 months ago

Hi @jonasvoelcker! Thank you for your response. I got the same error with 23.0.7 and 24.0.1. I used the different keycloak images and the different jar files from the latest release v5.11.1.

AssahBismarkabah commented 1 day ago

Hi @Clex1o1,

Thank you for bringing this issue up.

I replicated your setup using Keycloak version 23.0.1, keycloak-config-cli version 5.10, and the specified Docker Compose configuration. Everything functioned as expected.

The logs indicate a couple of warnings:

WARN[0000] /home/assah/Desktop/kc-cli-test/config/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion 
WARN[0000] Found orphan containers ([config-keycloak-config-cli-1]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. 
[+] Running 3/0
 ✔ Container config-adminer-1      Created                                                                        0.0s 
 ✔ Container config-keycloak-db-1  Created                                                                        0.0s 
 ✔ Container keycloak              Created                                                                        0.0s 
Attaching to adminer-1, keycloak-db-1, keycloak
keycloak-db-1  | 2024-10-17 13:05:05+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.5.2+maria~ubu2404 started.
adminer-1      | [Thu Oct 17 13:05:05 2024] PHP 7.4.33 Development Server (http://[::]:8080) started
keycloak-db-1  | 2024-10-17 13:05:05+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup///memory.pressure not writable, functionality unavailable to MariaDB
keycloak-db-1  | 2024-10-17 13:05:05+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
keycloak-db-1  | 2024-10-17 13:05:05+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.5.2+maria~ubu2404 started.
keycloak-db-1  | 2024-10-17 13:05:05+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
keycloak-db-1  | 2024-10-17 13:05:05 0 [Note] Starting MariaDB 11.5.2-MariaDB-ubu2404 source revision 
keycloak       | 2024-10-17 13:05:12,709 INFO  [io.quarkus] (main) Keycloak 23.0.1 on JVM (powered by Quarkus 3.2.9.Final) started in 5.949s. Listening on: http://0.0.0.0:8080
keycloak       | 2024-10-17 13:05:12,710 INFO  [io.quarkus] (main) Profile dev activated. 
keycloak       | 2024-10-17 13:05:12,710 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, jdbc-h2, jdbc-mariadb, jdbc-mssql, jdbc-mysql, jdbc-oracle, jdbc-postgresql, keycloak, logging-gelf, micrometer, narayana-jta, reactive-routes, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, smallrye-health, vertx]
keycloak       | 2024-10-17 13:05:12,808 WARN  [org.keycloak.quarkus.runtime.KeycloakMain] (main) Running the server in development mode. DO NOT use this configuration in production.

From my tests, all containers initialized without any errors, and Keycloak launched successfully. The problem you're experiencing may stem from a misconfiguration or could be environment-specific. It's also possible that this issue has already been resolved in a different context.

Sometimes, lingering containers or cached volumes can cause conflicts. You can try cleaning up the environment with

docker-compose down --volumes --remove-orphans
docker-compose up --build

if it will work for you, let me know if there are any other parameters that where taken into consideration that I missed out