SnuK87 / keycloak-kafka

Keycloak module to produce events to kafka
Apache License 2.0
100 stars 37 forks source link

Can't run Keycloak v26.0 #52

Closed alexeymarunin closed 3 days ago

alexeymarunin commented 4 days ago

Commands to build and run:

docker build -t keycloak-kafka .
 => [internal] load build definition from Dockerfile                                                                                                                              0.0s
 => => transferring dockerfile: 732B                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/keycloak/keycloak:26.0                                                                                                                 0.8s
 => [internal] load .dockerignore                                                                                                                                                 0.0s
 => => transferring context: 2B                                                                                                                                                   0.0s
 => [2/2] ADD https://github.com/SnuK87/keycloak-kafka/releases/download/1.2.0/keycloak-kafka-1.2.0-jar-with-dependencies.jar    /opt/keycloak/providers/keycloak-kafka-1.2.0-ja  1.0s
 => [1/2] FROM docker.io/keycloak/keycloak:26.0@sha256:089b5898cb0ba151224c83aef3806538582880029eb5ea71c2afd00b627d4907                                                           0.0s
 => CACHED [2/2] ADD https://github.com/SnuK87/keycloak-kafka/releases/download/1.2.0/keycloak-kafka-1.2.0-jar-with-dependencies.jar    /opt/keycloak/providers/keycloak-kafka-1  0.0s
 => exporting to image                                                                                                                                                            0.0s
 => => exporting layers                                                                                                                                                           0.0s
 => => writing image sha256:ccef2ebecf91ecccab4407fb5a6765c299cc02a66f98b213a0149480ed7c4b8d                                                                                      0.0s
 => => naming to docker.io/library/keycloak-kafka 

docker run --rm keycloak-kafka
Updating the configuration and installing your custom providers, if any. Please wait.
The DelayedHandler was closed before any children handlers were configured. Messages will be written to stderr.
2024-11-18 04:38:48,058 DEBUG [org.jboss.logging] (main) Logging Provider: org.jboss.logging.JBossLogManagerProvider

2024-11-18 04:38:48,637 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource with ordinal 2147483647

2024-11-18 04:38:48,637 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource DefaultValuesConfigSource with ordinal -2147483648

2024-11-18 04:38:48,647 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource with ordinal 2147483647

2024-11-18 04:38:48,647 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource DefaultValuesConfigSource with ordinal -2147483648

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource PropertiesConfigSource[source=CliConfigSource] with ordinal 600

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource KcEnvVarConfigSource with ordinal 500

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource QuarkusProperties with ordinal 450

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource file:/opt/keycloak/bin/../conf/keycloak.conf with ordinal 450

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource SysPropConfigSource with ordinal 400

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource EnvConfigSource with ordinal 300

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource PropertiesConfigSource[source=jar:file:///opt/keycloak/lib/app/keycloak.jar!/application.properties] with ordinal 250

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource PropertiesConfigSource[source=jar:file:///opt/keycloak/lib/lib/main/org.keycloak.keycloak-quarkus-server-26.0.5.jar!/application.properties] with ordinal 250

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource PersistedConfigSource with ordinal 200

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource jar:file:///opt/keycloak/lib/lib/main/org.keycloak.keycloak-quarkus-server-26.0.5.jar!/META-INF/keycloak.conf with ordinal 150

2024-11-18 04:38:48,648 DEBUG [io.smallrye.config] (main) SRCFG01006: Loaded ConfigSource DefaultValuesConfigSource with ordinal -2147483648

2024-11-18 04:38:48,735 TRACE [java.io.serialization] (main) Builtin factory: null -> new: null

2024-11-18 04:38:48,791 TRACE [java.io.serialization] (main) Builtin factory: null -> new: null

ERROR: Failed to run 'build' command.
For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.

Here is my Dockefile:

FROM keycloak/keycloak:26.0

ARG KAFKA_EXTENSION_VERSION=1.2.0

# https://github.com/keycloak/keycloak/issues/17438#issuecomment-1453817714
ADD https://github.com/SnuK87/keycloak-kafka/releases/download/${KAFKA_EXTENSION_VERSION}/keycloak-kafka-${KAFKA_EXTENSION_VERSION}-jar-with-dependencies.jar \
   /opt/keycloak/providers/keycloak-kafka-${KAFKA_EXTENSION_VERSION}-jar-with-dependencies.jar

ENV KAFKA_BOOTSTRAP_SERVERS=http://kafka:9092 \
    KAFKA_CLIENT_ID=bas \
    KAFKA_EVENTS=REGISTER,REGISTER_ERROR,LOGIN,LOGIN_ERROR,USER_INFO_REQUEST,USER_INFO_REQUEST_ERROR,LOGOUT,LOGOUT_ERROR \
    KAFKA_TOPIC=kcevents \
    KAFKA_ADMIN_TOPIC=kcaevents

CMD [ "start-dev" ]
SnuK87 commented 3 days ago

This is an issue with your Dockerfile. Plugin works fine with Keycloak 26.

alexeymarunin commented 3 days ago

I figured out the cause of the error

FROM keycloak/keycloak:26.0

ARG KAFKA_EXTENSION_VERSION=1.2.0

# Need correct user:group permissions for JAR-file
ADD --chown=keycloak:root \
    https://github.com/SnuK87/keycloak-kafka/releases/download/${KAFKA_EXTENSION_VERSION}/keycloak-kafka-${KAFKA_EXTENSION_VERSION}-jar-with-dependencies.jar \
   /opt/keycloak/providers/keycloak-kafka-${KAFKA_EXTENSION_VERSION}-jar-with-dependencies.jar

ENV KAFKA_BOOTSTRAP_SERVERS=http://kafka:9092 \
    KAFKA_CLIENT_ID=bas \
    KAFKA_EVENTS=REGISTER,REGISTER_ERROR,LOGIN,LOGIN_ERROR,USER_INFO_REQUEST,USER_INFO_REQUEST_ERROR,LOGOUT,LOGOUT_ERROR \
    KAFKA_TOPIC=kcevents \
    KAFKA_ADMIN_TOPIC=kcaevents

CMD [ "start-dev" ]

Now it's work fine :)