question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keycloak 17 quarkas distribution build failing after adding custom provider

See original GitHub issue

Describe the bug

I’ve some custom providers extending keycloak functionality by adding new rest endpoints, this used to work fine until we upgraded to keycloak 17 (Quarkas distribution), the build is failing with below error

ERROR: Failed to run 'build' command. ERROR: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 1 deployment problems: [1] Unsatisfied dependency for type org.keycloak.models.KeycloakSession and qualifiers [@Default] - java member: com.test.swagger.SwaggerJsonRetriever().session - declared on CLASS bean [types=[com.test.swagger.SwaggerJsonRetriever, java.lang.Object], qualifiers=[@Default, @Any], target=com.barco.edp.eis.apidoc.swagger.SwaggerJsonRetriever] The SwaggerJsonRetriever is a custom provider which implements RealmResourceProvider and it’s instance is being created by MetricsResourceProviderFactory whihc implements RealmResourceProviderFactory and all the ProviderFactory are listed under META-INF/services/org.keycloak.services.resource.RealmResourceProviderFactory.

I also made sure of that none of the keycloak libraries are packed into the jar (with dependencies) as well.

Is it a known issue or I’m missing some configuration.

Version

17.0.0

Expected behavior

The keycloak build should complete successfully and the rest endpoints should register and work.

Actual behavior

The keycloak build is failing after adding custom providers jars to {KEYCLOAK_HOME}/providers folder.

How to Reproduce?

Try adding a new custom provider to keycloak/providers folder and then run keycloak/binkc.sh build

Anything else?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nlmarcocommented, Sep 22, 2022

I’m using Keykloak 18.0.0 and I just encountered the same error.

I could not remove the @Path-annotation, because my RESTful interfaces come from a lib. I don’t want to copy (and modify) the interfaces, but use the original ones from the lib. The @Path is already in these interfaces – not in my Keycloak-specific implementation-class.

Fortunately, I found that adding a protected default-constructor (without any argument) to my RESTful resource-implementations solves the problem, too. This way, I could continue to use the real interfaces, even though they have the @Path-annotation, but Quarkus does not any longer try to inject the KeycloakSession. It seems to be smart enough to switch to the default-constructor during the kc.sh build-process.

During runtime, it uses my RealmResourceProviderFactory-implementations to create the instances, just like it did before with WildFly.

My default-constructors seem to be never actually used, which is good since they would throw exceptions 😏

1reaction
marcels2204commented, Mar 23, 2022

@akhil6095 I’ve successfully tested our custom SPI’s to Keycloak 17. What did you mean with “endpoints are not getting registered anymore.”? How do you deploy your SPI’s? Migrating to quarkus

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keycloak 17.0.0 released
Custom, and unsupported, Quarkus configuration is done through conf/quarkus.properties . Ability to add custom Java Options via ...
Read more >
Upgrading Guide - Keycloak
Default distribution is now powered by Quarkus; Migrating from the preview Quarkus distribution; Client Policies Migration : client-scopes ...
Read more >
Migrating to Quarkus distribution - Keycloak
Migrate to the new Quarkus distribution from the legacy WildFly distribution. In Keycloak 17 the ... Custom providers are packaged and deployed differently....
Read more >
Configuring Keycloak
Environment variables take precedence over options set by using a specific configuration file. Options from a specific config file take precedence over options ......
Read more >
Server Developer Guide - Keycloak
When implementing custom providers in Keycloak there may often be a need ... After re-augment the distribution with kc.sh build , the script ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found