Home > database >  Keycloak admin client not found in custom event listener
Keycloak admin client not found in custom event listener

Time:02-01

I'm developing a custom event listener for keycloak and I need the admin client (keycloak-admin-client) to use some methods. I've added the dependency in the pom file, and I'm generating the jar with: mvn clean install

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <keycloak.version>20.0.2</keycloak.version>

    <maven-compiler-plugin.version>3.10.0</maven-compiler-plugin.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-server-spi</artifactId>
        <version>${keycloak.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-server-spi-private</artifactId>
        <version>${keycloak.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-services</artifactId>
        <version>${keycloak.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-admin-client</artifactId>
        <version>${keycloak.version}</version>
    </dependency>
</dependencies>

The error I'm getting is:

2023-01-27 17:33:47,009 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-4) Uncaught server error: java.lang.NoClassDefFoundError: org/keycloak/admin/client/Keycloak

Also tried with <scope>provided</scope>. I have reviewed this post: KeyCloak custom REST Endpoint - Admin client classes not found which is exposing the same issue.

Edited: tried NoClassDefFoundError in a provider jar when using a class from org.keycloak.authentication.authenticators.broker.util without success.

CodePudding user response:

The solution has been provided by the amazing p2-inc team: solution to issue

  • Related