Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in building keycloak-json-remote-claim with Keycloak 18 #9

Open
fabiofarina opened this issue May 26, 2022 · 1 comment
Open

Comments

@fabiofarina
Copy link

fabiofarina commented May 26, 2022

Hello,
I'm trying to deploy keycloak-json-remote-claim with latest Keycloak but I get an error during the keycloak build step.

I attach the Dockerfile I'm using to create Keycloak image and the traceback I get.

Could anyone help in understanding what's wrong? Thanks in advance

## Create custom SPI
FROM maven:3.8.5-jdk-11-slim AS packager
RUN apt update -y && apt install git -y && \
    mkdir -p /home/app && \
    cd /home/app && \
    git clone https://github.com/groupr-sii/keycloak-json-remote-claim.git && \
    mvn -f /home/app/keycloak-json-remote-claim/pom.xml clean package

## Create Keycloak image  -- fase 1 build
FROM quay.io/keycloak/keycloak:18.0 as builder
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_DB=postgres
COPY --from=packager /home/app/keycloak-json-remote-claim/target/json-remote-claim.jar /opt/keycloak/providers/json-remote-claim.jar
RUN curl -sL https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar -o /opt/keycloak/providers/keycloak-metrics-spi-2.5.3.jar
RUN /opt/keycloak/bin/kc.sh build

## Create Keycloak image -- fase 2 start
FROM quay.io/keycloak/keycloak:18.0

COPY --from=builder /opt/keycloak/ /opt/keycloak/
WORKDIR /opt/keycloak

ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start"]

And this is the error by Docker build

Step 9/13 : RUN /opt/keycloak/bin/kc.sh build
 ---> Running in f8fc4a6aa904
Updating the configuration and installing your custom providers, if any. Please wait.
2022-05-26 10:37:16,002 WARN  [org.keycloak.services] (build-47) KC-SERVICES0047: metrics (org.jboss.aerogear.keycloak.metrics.MetricsEndpointFactory) is implementing the internal SPI realm-restapi-extension. This SPI is internal and may change without notice
ERROR: Failed to run 'build' command.
ERROR: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step org.keycloak.quarkus.deployment.KeycloakProcessor#configureProviders threw an exception: java.util.ServiceConfigurationError: org.keycloak.protocol.ProtocolMapper: Provider fr.sii.keycloak.JsonRemoteClaim could not be instantiated
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:804)
        at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:722)
        at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
        at org.keycloak.provider.DefaultProviderLoader.load(DefaultProviderLoader.java:60)
        at org.keycloak.provider.ProviderManager.load(ProviderManager.java:94)
        at org.keycloak.quarkus.deployment.KeycloakProcessor.loadFactories(KeycloakProcessor.java:515)
        at org.keycloak.quarkus.deployment.KeycloakProcessor.configureProviders(KeycloakProcessor.java:279)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.ExceptionInInitializerError
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:780)
        ... 17 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
        at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:102)
        at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:113)
        at fr.sii.keycloak.JsonRemoteClaim.<clinit>(JsonRemoteClaim.java:35)
        ... 22 more
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at javax.ws.rs.client.FactoryFinder.newInstance(FactoryFinder.java:93)
        at javax.ws.rs.client.FactoryFinder.find(FactoryFinder.java:210)
        at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:69)
        ... 24 more

ERROR: Build failure: Build failed due to errors
        [error]: Build step org.keycloak.quarkus.deployment.KeycloakProcessor#configureProviders threw an exception: java.util.ServiceConfigurationError: org.keycloak.protocol.ProtocolMapper: Provider fr.sii.keycloak.JsonRemoteClaim could not be instantiated
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:804)
        at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:722)
        at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
        at org.keycloak.provider.DefaultProviderLoader.load(DefaultProviderLoader.java:60)
        at org.keycloak.provider.ProviderManager.load(ProviderManager.java:94)
        at org.keycloak.quarkus.deployment.KeycloakProcessor.loadFactories(KeycloakProcessor.java:515)
        at org.keycloak.quarkus.deployment.KeycloakProcessor.configureProviders(KeycloakProcessor.java:279)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.ExceptionInInitializerError
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:780)
        ... 17 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
        at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:102)
        at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:113)
        at fr.sii.keycloak.JsonRemoteClaim.<clinit>(JsonRemoteClaim.java:35)
        ... 22 more
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at javax.ws.rs.client.FactoryFinder.newInstance(FactoryFinder.java:93)
        at javax.ws.rs.client.FactoryFinder.find(FactoryFinder.java:210)
        at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:69)
        ... 24 more

ERROR: org.keycloak.protocol.ProtocolMapper: Provider fr.sii.keycloak.JsonRemoteClaim could not be instantiated
ERROR: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
ERROR: org.glassfish.jersey.client.JerseyClientBuilder
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.
The command '/bin/sh -c /opt/keycloak/bin/kc.sh build' returned a non-zero code: 1
@BerendWouters
Copy link

@fabiofarina I like your fix on your fork, it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants