Issue
I'm creating a Keycloak extension with dependencies. I added the entry on the pom.xml
like this:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
Then I deployed it to Keycloak:
mvn clean install wildfly:deploy
But when I run it, I got the error:
org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError: org/json/JSONObject
Caused by: java.lang.NoClassDefFoundError: org/json/JSONObject
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject from [Module "deployment.keycloak-authenticator.jar" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 66 more
How to add dependencies to extensions in Keycloak?
Solution
There is a better way, deploy as a EAR archive. This project shows how to: https://github.com/stianst/keycloak-experimental/tree/master/fido-u2f
Answered By - rigon
Answer Checked By - Mary Flores (JavaFixing Volunteer)