quarkus
quarkus copied to clipboard
Keycloak admin client fail with "authHeader" is null when using classic extensions
Describe the bug
Here is a previous issue which seems to be fixed and closed, could be related: https://github.com/quarkusio/quarkus/issues/30089.
When I inject org.keycloak.admin.client.Keycloak and try to call some method (e.g. keycloak.serverInfo().getInfo()) it is giving me the following error:
Caused by: java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "authHeader" is null
at org.keycloak.admin.client.resource.BearerAuthFilter.filter(BearerAuthFilter.java:53)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.filterRequest(ClientInvocation.java:644)
It is only happening when using classic extensions, when using reactive extensions it is working fine. For the test I'm using latest Quarkus (3.4.2) and latest LTS version (3.2.6.Final), with these extensions it is not working:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-keycloak-admin-client</artifactId>
</dependency>
But if I use reactive extensions it is working fine:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-keycloak-admin-client-reactive</artifactId>
</dependency>
Expected behavior
Behaviour should be the same as when using reactive extensions.
Actual behavior
It is throwing NPE error.
How to Reproduce?
Here is a minimum reproduction case (freshly generated Quarkus project). In pom there are classic extensions and commented out reactive extension. Also in the application properties there are basic properties for keycloak admin client.
Output of uname -a
or ver
No response
Output of java -version
java version "1.8.0_381" Java(TM) SE Runtime Environment (build 1.8.0_381-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode)
and
openjdk version "17.0.8" 2023-07-18 OpenJDK Runtime Environment Temurin-17.0.8+7 (build 17.0.8+7) OpenJDK 64-Bit Server VM Temurin-17.0.8+7 (build 17.0.8+7, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.4.2 and 3.2.6.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
apache-maven-3.9.5
Additional information
No response
/cc @pedroigor (keycloak), @sberyozkin (keycloak)
Sadge, getting the same error in 3.6.4 as wel. With all reactive extensions:
- quarkus-resteasy-reactive-jackson. or quarkus-resteasy-reactive-jsonb
- quarkus-keycloak-admin-client-reactive
It also occurs in 3.6.4 with the following setup:
- quarkus-resteasy
- quarkus-resteasy-jsonb
- quarkus-keycloak-admin-client
The issue is solved when using the following combination:
- quarkus-resteasy
- quarkus-resteasy-jackson
- quarkus-keycloak-admin-client
@sberyozkin this issue is an impedement for us to go to production. Can this be fixed in 3.7 🚀
Detected the same issue as well with 3.7.3 using:
- quarkus-resteasy-reactive
- quarkus-resteasy-reactive-jsonb
- quarkus-rest-client-reactive-jsonb
- quarkus-keycloak-admin-client-reactive
hello @maxlam79 this is issue for RESTEasy Classic, there is palpable difference on implementation side. If you provide a reproduce for RESTEasy Reactive, I'll have a look.
@michalvavrik , ooppss...sorry. I have created a separate issue here. Thank you.
I'll check what we can do for RESTEasy Classic version.