Repository navigation
Description
Describe the bug
KC 15 & KC16 contain in the main pom.xml the dependency for the rest client
<resteasy.version>3.15.1.Final</resteasy.version>
<resteasy.undertow.version>${resteasy.version}</resteasy.undertow.version>
The problem is that, under KC 16.1.0 on containers with the Wildfly server, we found out that the related execution version from the server is
<resteasy.version>4.5.9.Final</resteasy.version>
Version
16.1.0
Expected behavior
The pom.xml should be updated to
<resteasy.version>4.5.9.Final</resteasy.version>
Actual behavior
There is API inconsistency while extending the project. This concept affects KC16 upgrade with custom libraries.
We needed to rewrite the resteasy library dependency, which it can drive to future update-problems.
How to Reproduce?
Generate a custom module and introduce the following code:
(Resteasy v3.x)
HttpServletResponse contextData = ResteasyProviderFactory.getContextData(HttpServletResponse.class);
(Solved with resteasy v4.x)
HttpServletResponse contextData = ResteasyProviderFactoryImpl.getInstance().getContextData(HttpServletResponse.class); ResteasyProviderFactory
You will have an execution error on a KC16 wildfly server when the module is called, with the following stacktrace:
09:09:44,695 ERROR [org.keycloak.events.EventBuilder] (default task-26) Failed to send type to com.custom.keycloak.providers.events.MyErrorClass@647f9648: java.lang.IncompatibleClassChangeError: Expected static method 'java.lang.Object org.jboss.resteasy.spi.ResteasyProviderFactory.getContextData(java.lang.Class)'
...
at org.keycloak.keycloak-server-spi-private@16.1.0//org.keycloak.events.EventBuilder.send(EventBuilder.java:229)
at org.keycloak.keycloak-server-spi-private@16.1.0//org.keycloak.events.EventBuilder.success(EventBuilder.java:192)
at org.keycloak.keycloak-services@16.1.0//org.keycloak.services.managers.AuthenticationManager.finishedRequiredActions(AuthenticationManager.java:1031)
at org.keycloak.keycloak-services@16.1.0//org.keycloak.authentication.AuthenticationProcessor.authenticationComplete(AuthenticationProcessor.java:1091)
at org.keycloak.keycloak-services@16.1.0//org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:958)
at org.keycloak.keycloak-services@16.1.0//org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:312)
at org.keycloak.keycloak-services@16.1.0//org.keycloak.services.resources.LoginActionsService.processAuthentication(LoginActionsService.java:283)
at org.keycloak.keycloak-services@16.1.0//org.keycloak.services.resources.LoginActionsService.authenticate(LoginActionsService.java:267)
at org.keycloak.keycloak-services@16.1.0//org.keycloak.services.resources.LoginActionsService.authenticateForm(LoginActionsService.java:340)
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 org.jboss.resteasy.resteasy-core@4.7.4.Final//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
at org.jboss.resteasy.resteasy-core@4.7.4.Final//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
at org.jboss.resteasy.resteasy-core@4.7.4.Final//org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(
Detail info has been inform in https://stackoverflow.com/questions/66701269/resteasyclient-incompatibleclasschangeerror-resteasyproviderfactory-getcontextd
Anything else?
No response
Activity
joeri-jansen commentedon Jan 19, 2022
I can confirm this issue. I get errors like these:
[org.keycloak.services.error.KeycloakErrorHandler] (default task-23) Uncaught server error: java.lang.NoSuchMethodError: 'org.jboss.resteasy.spi.ResteasyUriInfo org.jboss.resteasy.spi.HttpRequest.getUri()'
Gradle dependency tree:
+--- org.keycloak:keycloak-services:16.1.0
| +--- org.jboss.resteasy:resteasy-multipart-provider:3.15.1.Final
Packaged runtime:
4.7.4.Final
stianst commentedon Jan 27, 2022
I'm afraid this is something we have to live with for a little bit since the Keycloak parent is shared between Quarkus dist, WildFly dist, and adapters.
In the meantime I suggest using the BOMs for WildFly or Quarkus to get the correct dependencies.
CollinAlpert commentedon Mar 8, 2022
@stianst I am also running into the
NoSuchMethodErrorwhen callinggetUri(). Is there any workaround for this right now?joeri-jansen commentedon Mar 8, 2022
For me, adding these gradle dependencies to my project, fixed the issue:
// Fix for #9599 set resteasy depencencies explicit to version packaged with Keycloak
versions.resteasy = '4.7.4.Final'
compileOnly 'org.jboss.resteasy:resteasy-client:' + versions.resteasy
compileOnly 'org.jboss.resteasy:resteasy-jackson2-provider:' + versions.resteasy
compileOnly 'org.jboss.resteasy:resteasy-multipart-provider:' + versions.resteasy
compileOnly 'org.jboss.resteasy:resteasy-jaxb-provider:' + versions.resteasy
CollinAlpert commentedon Mar 10, 2022
@joeri-jansen Thanks a lot, this works. I have found that adding only
resteasy-multipart-provideris enough.abstractj commentedon Mar 10, 2022
@stianst there's a mismatch between the current RESTEasy versions:
For the Operator, I already submitted a ticket #10702. Should we create a ticket to update the main POM? Considering that the Quarkus distribution is up-to-date, the deprecation of our adapters, and we will face several breaking changes, I wanted to double-check with you if worth the effort.
fixed magic-link compatibility error with latest keycloak release @see …
abstractj commentedon Apr 7, 2022
The mismatch between the Operator and Quarkus distribution was fixed, please see:
It is still necessary to update the main POM file, and Pedro started to work on this. Please check: #10917
abstractj commentedon Dec 22, 2022
Resolved #10917