mitodl / keycloak-scim

SCIM client plugin for Keycloak
Apache License 2.0
25 stars 2 forks source link

Provider sh.libre.scim.storage.ScimStorageProviderFactory could not be instantiated #103

Open JacobHicksSponge opened 2 days ago

JacobHicksSponge commented 2 days ago

I'm wanting to test out this extension for a proof-of-concept, but am running in to an error when trying to install it with the quick installation steps. Please let me know if you think I'm missing anything in the steps I'm following

Expected Behavior

I would expect the steps I'm following to install keycloak-scim and make the functionality available in a local dev environment of Keycloak.

Current Behavior

Instead I am seeing the following error (note this is the end of it but the full output is very long):

ERROR: Build failure: Build failed due to errors
    [error]: Build step org.keycloak.quarkus.deployment.KeycloakProcessor#configureKeycloakSessionFactory threw an exception: java.util.ServiceConfigurationError: org.keycloak.storage.UserStorageProviderFactory: Provider sh.libre.scim.storage.ScimStorageProviderFactory could not be instantiated
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
    at org.keycloak.provider.DefaultProviderLoader.load(DefaultProviderLoader.java:60)
    at org.keycloak.provider.ProviderManager.load(ProviderManager.java:93)
    at org.keycloak.quarkus.deployment.KeycloakProcessor.loadFactories(KeycloakProcessor.java:690)
    at org.keycloak.quarkus.deployment.KeycloakProcessor.configureKeycloakSessionFactory(KeycloakProcessor.java:398)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
    at java.base/java.lang.Thread.run(Thread.java:840)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/core/MediaType
    at com.unboundid.scim2.client.ScimService.<clinit>(ScimService.java:65)
    at sh.libre.scim.storage.ScimStorageProviderFactory.<clinit>(ScimStorageProviderFactory.java:46)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
    ... 17 more
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.core.MediaType
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:520)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:468)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:518)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:468)
    ... 25 more

ERROR: org.keycloak.storage.UserStorageProviderFactory: Provider sh.libre.scim.storage.ScimStorageProviderFactory could not be instantiated
ERROR: javax/ws/rs/core/MediaType
ERROR: javax.ws.rs.core.MediaType

Steps to Reproduce

  1. Run keycloak: docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:25.0.1 start-dev
  2. Use docker ps to get ID of container - eg: 50e04c077e09
  3. Download latest version: keycloak-scim-1.0-SNAPSHOT-all.jar
  4. Copy in to running container: docker cp ~/Downloads/keycloak-scim-1.0-SNAPSHOT-all.jar 50e04c077e09:/opt/keycloak/providers/.
  5. Open container shell: docker exec -it 50e04c077e09 bash
  6. Re-build: /opt/keycloak/bin/kc.sh build
shaidar commented 2 days ago

I ran the steps you mentioned trying to reproduce the error, however I was unable to. I initially thought it might be a breaking change in the new version of Keycloak so I tested out 24.0.0 and that worked fine. I then tested 25.0.1 and I still didn't run into issues when following the steps referenced.

➜  ~ docker cp ~/Downloads/keycloak-scim-1.0-SNAPSHOT-all.jar 5c4580678699:/opt/keycloak/providers/
Successfully copied 15.2MB to 5c4580678699:/opt/keycloak/providers/
➜  ~ docker exec -it 5c4580678699 bash
bash-5.1$ /opt/keycloak/bin/kc.sh build
Updating the configuration and installing your custom providers, if any. Please wait.
2024-07-02 14:41:47,246 WARN  [org.key.services] (build-50) KC-SERVICES0047: scim-resource (sh.libre.scim.jpa.ScimResourceProviderFactory) is implementing the internal SPI jpa-entity-provider. This SPI is internal and may change without notice
2024-07-02 14:41:47,330 WARN  [org.key.services] (build-50) KC-SERVICES0047: scim (sh.libre.scim.event.ScimEventListenerProviderFactory) is implementing the internal SPI eventsListener. This SPI is internal and may change without notice
2024-07-02 14:41:49,378 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 2786ms
Server configuration updated and persisted. Run the following command to review the configuration:

    kc.sh show-config

bash-5.1$ /opt/keycloak/bin/kc.sh show-config
Current Mode: production
Current Configuration:
    kc.config.built =  true (SysPropConfigSource)
    kc.db =  dev-file (Persisted)
    kc.log-console-output =  default (classpath keycloak.conf)
    kc.optimized =  true (Persisted)
    kc.provider.file.keycloak-scim-1.0-SNAPSHOT-all.jar.last-modified =  1719927878000 (Persisted)
    kc.run.in.container =  true (ENV)
    kc.version =  25.0.1 (SysPropConfigSource)
JacobHicksSponge commented 2 days ago

Thanks for checking it out @shaidar - I'll experiment a bit more to see if I can figure out why it's not working and report back if I can find a solution. Let me know if you have any ideas for things I can try that may be different on my system compared to yours.

I can run /opt/keycloak/bin/kc.sh build fine if I move keycloak-scim-1.0-SNAPSHOT-all.jar out of the /opt/keycloak/providers/ directory and then running /opt/keycloak/bin/kc.sh show-config gives me (note I tested it with Keycloak 24.0.2 this time):

bash-5.1$ bin/kc.sh show-config
Current Mode: production
Current Configuration:
    kc.config.built =  true (SysPropConfigSource)
    kc.db =  dev-file (PersistedConfigSource)
    kc.log-console-output =  default (PropertiesConfigSource[source=jar:file:///opt/keycloak/lib/lib/main/org.keycloak.keycloak-quarkus-server-24.0.2.jar!/META-INF/keycloak.conf])
    kc.log-file =  ${kc.home.dir:default}${file.separator}data${file.separator}log${file.separator}keycloak.log (PropertiesConfigSource[source=jar:file:///opt/keycloak/lib/lib/main/org.keycloak.keycloak-quarkus-server-24.0.2.jar!/META-INF/keycloak.conf])
    kc.optimized =  true (PersistedConfigSource)
    kc.run.in.container =  true (KcEnvVarConfigSource)
    kc.version =  24.0.2 (SysPropConfigSource)