Closed escribano89 closed 1 year ago
The keycloak-admin-client
and its dependencies are not included by default with Keycloak. In order to run extensions that require it, you have to include it. Check out this pom https://github.com/p2-inc/phasetwo-containers/blob/main/libs/pom.xml for an example of how to collect the appropriate libraries. I use this to build an ear
file, but don't use it (Keycloak no longer supports deployment from ear
files), but I just copy the jars from the unpacked target dir.
Thanks for your quick answer, I really appreciate it. I'm novel on keycloak and Java is not my main language. Yes, I'm using a pom, and I'm including the dependency. Then I generate the jar using mvn clean install and I move the jar to the providers folder. But I'm getting the same error. This is my pom file based on your provided example:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test.auth</groupId>
<artifactId>user-created-event-listener</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<includeLibInApplicationXml>true</includeLibInApplicationXml>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<keycloak.version>20.0.2</keycloak.version>
<resteasy.version>4.7.5.Final</resteasy.version>
<keycloak-orgs.version>[0.5,)</keycloak-orgs.version>
<keycloak-themes.version>[0.8,)</keycloak-themes.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>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${resteasy.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client-api</artifactId>
<version>${resteasy.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Almost there. Try the following.
<packaging>ear</packaging>
mvn install
target/user-created-event-listener-0.0.1-SNAPSHOT.jar
to the providers dirtarget/user-created-event-listener-0.0.1-SNAPSHOT/*.jar
to the providers dirYour target/
dir layout should look like this after running mvn install
target/
├── application.xml
├── maven-archiver
│ └── pom.properties
├── user-created-event-listener-0.0.1-SNAPSHOT
│ ├── META-INF
│ │ └── application.xml
│ ├── org.jboss.resteasy-resteasy-client-4.7.5.Final.jar
│ ├── org.jboss.resteasy-resteasy-client-api-4.7.5.Final.jar
│ └── org.keycloak-keycloak-admin-client-20.0.2.jar
├── user-created-event-listener-0.0.1-SNAPSHOT.ear
└── user-created-event-listener-0.0.1-SNAPSHOT.jar
It's working right now. Thank you very much. It has been crazy to try to find the solution out there. Very very helpful.
Great. Glad this worked for you.
Thanks for your contribution to Keycloak, it's really amazing. I'm trying to use the keycloak-admin-client within a custom event listener, but I'm getting the below error during the runtime (loading Events tab). Please note that I'm using the same pom structure as you are using the keycloak-events. The version of keycloak is 20.0.2: