Closed NikosKoukoumelis closed 1 year ago
Sorry, I can't read that stack trace.
Thanks for your immediate response, I have edited my original comment. Is it more readable now?
Yes. Thanks. There are some inconsistencies with how the KeycloakContext is populated based on how the event gets invoked. We had another bug similar to this, and we thought we fixed all cases. I’ll take a look and see if this is one we didn’t anticipate.
Can you provide some more details? Is it throwing this error on all events, or just certain types?
We are not sure which are the types of events that cause the error but we know that LOGIN_ERROR
and CLIENT_LOGIN_ERROR
produce it.
Sorry, would you mind turning off JSON logging or whatever you're running and pasting a full stack trace of what you're seeing? I'm not able to reproduce, and won't be able to figure out where it's happening without a real stack trace.
Also, paste the config from the realm attribute you're using (remove any sensitive information).
Looks like it is related to this in Keycloak https://github.com/keycloak/keycloak/issues/20105
If the KeycloakContext realm isn't properly getting set, the ConfigurationAware lookup method will throw this exception. Should be fixed in KC 22.
Not sure if any of these will work for you, because I haven't been able to recreate the problem, but if you can try this branch, please do and let me know if it works: https://github.com/p2-inc/keycloak-events/tree/xgp/get-realm-context-bug
We tried out the branch and we kept getting the error, I am attaching a file with the full stack trace. I am coming back shortly with the realm attribute config. log.txt
Here is the realm attribute config realm_attribute_202307101613.txt
Thanks for you help.
@NikosKoukoumelis Thanks for the clean stack trace. I was able to reproduce, and it's because of the bug https://github.com/keycloak/keycloak/issues/20105 in Keycloak that was introduced in version 21.1.x
. There isn't a workaround in this case, because there is no other way for this code to get the Realm. The Keycloak maintainers have indicated that the fix will be in version 22
.
@NikosKoukoumelis Keycloak 22.0.0
is out today. It includes a fix for https://github.com/keycloak/keycloak/issues/20105 which should fix this issue. I will test this against the upgraded version in the next few days, but you might want to try that version now if you are in a hurry.
@xgp We updated keycloak and got the latest release of keycloak-events, no error is thrown now. Thanks for your help and guidance!
Hello,
After upgrading keycloak from version 20.0.5 to 21.1.1 and keycloak-events jar file from version 0.8 to 0.17 we started receiving errors from ext-event-http event listener.
The exception message we get is the following:
Uncaught server error: Cannot invoke "org.keycloak.models.RealmModel.getName()" because the return value of "org.keycloak.models.KeycloakContext.getRealm()" is null
and the stack trace is the following:
Can you assist us to overcome this if it is not a bug?
Thanks in advance.