Search code examples
jettykeycloakapache-karaf

Keycloak jetty adapter cannot be installed in Apache Karaf


I use Apache Karaf 4.2.8. I installed keycloak osgi features. I could configure authentication for karaf shell with keycloak using keycloak-jaas feature.

Now I want to configure authentication for my services under /cxf context.

I configured pax-web context so login-method is KEYCLOAK.

But I have to install keycloak-jetty-adapter as well, so it could be integrated. But when I try to install that feature I receive an error.

trun()> feature:install keycloak-jetty9-adapter

org.apache.felix.resolver.reason.ReasonException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=keycloak-jetty9-adapter; type=karaf.feature; version="[8.0.1,8.0.1]"; filter:="(&(osgi.identity=keycloak-jetty9-adapter)(type=karaf.feature)(version>=8.0.1)(version<=8.0.1))" [caused by: Unable to resolve keycloak-jetty9-adapter/8.0.1: missing requirement [keycloak-jetty9-adapter/8.0.1] osgi.identity; osgi.identity=jetty; type=karaf.feature; version="[9.2.0,9.3.0)"] at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343) at org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:392) at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:378) at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:332) at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:257) at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:388) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1058) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:994) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to resolve keycloak-jetty9-adapter/8.0.1: missing requirement [keycloak-jetty9-adapter/8.0.1] osgi.identity; osgi.identity=jetty; type=karaf.feature; version="[9.2.0,9.3.0)" at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343) ... 12 more Error executing command: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=keycloak-jetty9-adapter; type=karaf.feature; version="[8.0.1,8.0.1]"; filter:="(&(osgi.identity=keycloak-jetty9-adapter)(type=karaf.feature)(version>=8.0.1)(version<=8.0.1))" [caused by: Unable to resolve keycloak-jetty9-adapter/8.0.1: missing requirement [keycloak-jetty9-adapter/8.0.1] osgi.identity; osgi.identity=jetty; type=karaf.feature; version="[9.2.0,9.3.0)"]

If not to install that adapter, then I cannot reach my service (I receive 403 Forbidden) as it is protected via pax-web but authentication is impossible.

It seems that jetty within karaf is embedded and does not contain all features, which does not allow me to install jetty adapter.


Solution

  • According to the release notes for Apache Karaf 4.2.8, Karaf is using Jetty 9.4.22, which seems to be outside of your range in the error message version="[9.2.0,9.3.0)"

    You'll either need to upgrade Keycloak to one that support Jetty 9.4.x or downgrade Karaf to one that supports the same version of Jetty that Keycloak uses.