build - Type 'orgjbossresteasyspecimplResteasyUriBuilderImpl' (current frame, stack[0]) is not assignable to &am

admin2025-04-17  3

I am upgrading from Keycloak 12 to Keycloak 26 and adapting custom providers for this version. During a procedure, I get the following error:

2025-01-30 15:12:45,024 ERROR [org.keycloak.events.EventBuilder] (executor-thread-1) Failed to send type to keycloak-provider: java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    org/jboss/resteasy/core/providerfactory/Utils.createUriBuilder()Ljavax/ws/rs/core/UriBuilder; @7: areturn
  Reason:
    Type 'org/jboss/resteasy/specimpl/ResteasyUriBuilderImpl' (current frame, stack[0]) is not assignable to 'javax/ws/rs/core/UriBuilder' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { }
    stack: { 'org/jboss/resteasy/specimpl/ResteasyUriBuilderImpl' }
  Bytecode:
    0000000: bb00 2659 b700 27b0

Full stack trace:

                        at org.jboss.resteasy.core.providerfactory.CommonProviders.processProviderContracts(CommonProviders.java:82)
                        at org.jboss.resteasy.core.providerfactory.ClientHelper.processProviderContracts(ClientHelper.java:104)
                        at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.processProviderContracts(ResteasyProviderFactoryImpl.java:841)
                        at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.registerProvider(ResteasyProviderFactoryImpl.java:829)
                        at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.registerProvider(ResteasyProviderFactoryImpl.java:816)
                        at org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:109)
                        at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:74)
                        at org.jboss.resteasy.plugins.providers.RegisterBuiltin.getClientInitializedResteasyProviderFactory(RegisterBuiltin.java:54)
                        at org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl.getProviderFactory(ResteasyClientBuilderImpl.java:357)
                        at org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl.build(ResteasyClientBuilderImpl.java:373)
                        at provider.SSOGeneralFederationKCAuthorization.getToken(KCAuthorization.java:27)
                        at provider.EventListenerProvider.asyncSearch(EventListenerProvider.java:97)
                        at provider.EventListenerProvider.onEvent(EventListenerProvider.java:39)
                        at org.keycloak.events.EventBuilder.sendNow(EventBuilder.java:262)
                        at org.keycloak.events.EventBuilder.send(EventBuilder.java:249)
                        at org.keycloak.events.EventBuilder.success(EventBuilder.java:217)
                        at org.keycloak.authentication.forms.RegistrationUserCreation.success(RegistrationUserCreation.java:174)
                        at org.keycloak.authentication.FormAuthenticationFlow.processAction(FormAuthenticationFlow.java:253)
                        at org.keycloak.authentication.DefaultAuthenticationFlow.processAction(DefaultAuthenticationFlow.java:128)
                        at org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:1034)
                        at org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:378)
                        at org.keycloak.services.resources.LoginActionsService.processRegistration(LoginActionsService.java:747)
                        at org.keycloak.services.resources.LoginActionsService.registerRequest(LoginActionsService.java:811)
                        at org.keycloak.services.resources.LoginActionsService.processRegister(LoginActionsService.java:789)
                        at org.keycloak.services.resources.LoginActionsService$quarkusrestinvoker$processRegister_7a9f3962753907b18ff9c85418d7f9feed84dedc.invoke(Unknown Source)
                        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
                        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
                        at org.jboss.resteasy.reactivemon.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
                        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
                        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
                        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
                        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
                        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
                        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
                        at ioty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
                        at java.base/java.lang.Thread.run(Thread.java:842)

The method causing the issue:

public static String getToken() {
    Keycloak keycloak = KeycloakBuilder
            .builder()
            .serverUrl(propertiesService.getProperty(URL_KEYCLOAK_SERVER))
            .realm(REALM_MASTER)
            .username(USERNAME_ADMIN)
            .password(PASSWORD_ADMIN)
            .clientId(CLIENT_ADMIN)
            .resteasyClient(new ResteasyClientBuilderImpl().connectionPoolSize(10).build())
            .build();
    return keycloak.tokenManager().getAccessTokenString();
}

pom.xml dependencies:

<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-core</artifactId>
    <version>26.0.3</version>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-admin-client</artifactId>
    <version>26.0.4</version>
</dependency>

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>6.2.11.Final</version>
    <exclusions>
        <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>jakarta.ws.rs</groupId>
    <artifactId>jakarta.ws.rs-api</artifactId>
    <version>3.1.0</version>
</dependency>

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-core</artifactId>
    <version>4.7.9.Final</version>
    <exclusions>
        <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Additional JARs in the providers folder:

  • jakarta.ws.rs-api-4.0.0.jar

  • javax.ws.rs-api-2.1.1.jar

  • json-20240303.jar

  • keycloak-admin-client-26.0.4.jar

  • resteasy-client-6.2.11.Final.jar

  • resteasy-core-4.7.9.Final.jar

  • resteasy-jackson2-provider-4.7.9.Final.jar

  • resteasy-multipart-provider-6.2.11.Final.jar

  • wildfly-client-config-1.0.1.Final.jar

I suspect a conflict between jakarta.ws.rs and javax.ws.rs, but I am unsure how to resolve it.

How can I fix it?

I am upgrading from Keycloak 12 to Keycloak 26 and adapting custom providers for this version. During a procedure, I get the following error:

2025-01-30 15:12:45,024 ERROR [org.keycloak.events.EventBuilder] (executor-thread-1) Failed to send type to keycloak-provider: java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    org/jboss/resteasy/core/providerfactory/Utils.createUriBuilder()Ljavax/ws/rs/core/UriBuilder; @7: areturn
  Reason:
    Type 'org/jboss/resteasy/specimpl/ResteasyUriBuilderImpl' (current frame, stack[0]) is not assignable to 'javax/ws/rs/core/UriBuilder' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { }
    stack: { 'org/jboss/resteasy/specimpl/ResteasyUriBuilderImpl' }
  Bytecode:
    0000000: bb00 2659 b700 27b0

Full stack trace:

                        at org.jboss.resteasy.core.providerfactory.CommonProviders.processProviderContracts(CommonProviders.java:82)
                        at org.jboss.resteasy.core.providerfactory.ClientHelper.processProviderContracts(ClientHelper.java:104)
                        at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.processProviderContracts(ResteasyProviderFactoryImpl.java:841)
                        at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.registerProvider(ResteasyProviderFactoryImpl.java:829)
                        at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.registerProvider(ResteasyProviderFactoryImpl.java:816)
                        at org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:109)
                        at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:74)
                        at org.jboss.resteasy.plugins.providers.RegisterBuiltin.getClientInitializedResteasyProviderFactory(RegisterBuiltin.java:54)
                        at org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl.getProviderFactory(ResteasyClientBuilderImpl.java:357)
                        at org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl.build(ResteasyClientBuilderImpl.java:373)
                        at provider.SSOGeneralFederationKCAuthorization.getToken(KCAuthorization.java:27)
                        at provider.EventListenerProvider.asyncSearch(EventListenerProvider.java:97)
                        at provider.EventListenerProvider.onEvent(EventListenerProvider.java:39)
                        at org.keycloak.events.EventBuilder.sendNow(EventBuilder.java:262)
                        at org.keycloak.events.EventBuilder.send(EventBuilder.java:249)
                        at org.keycloak.events.EventBuilder.success(EventBuilder.java:217)
                        at org.keycloak.authentication.forms.RegistrationUserCreation.success(RegistrationUserCreation.java:174)
                        at org.keycloak.authentication.FormAuthenticationFlow.processAction(FormAuthenticationFlow.java:253)
                        at org.keycloak.authentication.DefaultAuthenticationFlow.processAction(DefaultAuthenticationFlow.java:128)
                        at org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:1034)
                        at org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:378)
                        at org.keycloak.services.resources.LoginActionsService.processRegistration(LoginActionsService.java:747)
                        at org.keycloak.services.resources.LoginActionsService.registerRequest(LoginActionsService.java:811)
                        at org.keycloak.services.resources.LoginActionsService.processRegister(LoginActionsService.java:789)
                        at org.keycloak.services.resources.LoginActionsService$quarkusrestinvoker$processRegister_7a9f3962753907b18ff9c85418d7f9feed84dedc.invoke(Unknown Source)
                        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
                        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
                        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
                        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
                        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
                        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
                        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
                        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
                        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
                        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
                        at java.base/java.lang.Thread.run(Thread.java:842)

The method causing the issue:

public static String getToken() {
    Keycloak keycloak = KeycloakBuilder
            .builder()
            .serverUrl(propertiesService.getProperty(URL_KEYCLOAK_SERVER))
            .realm(REALM_MASTER)
            .username(USERNAME_ADMIN)
            .password(PASSWORD_ADMIN)
            .clientId(CLIENT_ADMIN)
            .resteasyClient(new ResteasyClientBuilderImpl().connectionPoolSize(10).build())
            .build();
    return keycloak.tokenManager().getAccessTokenString();
}

pom.xml dependencies:

<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-core</artifactId>
    <version>26.0.3</version>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-admin-client</artifactId>
    <version>26.0.4</version>
</dependency>

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>6.2.11.Final</version>
    <exclusions>
        <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>jakarta.ws.rs</groupId>
    <artifactId>jakarta.ws.rs-api</artifactId>
    <version>3.1.0</version>
</dependency>

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-core</artifactId>
    <version>4.7.9.Final</version>
    <exclusions>
        <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Additional JARs in the providers folder:

  • jakarta.ws.rs-api-4.0.0.jar

  • javax.ws.rs-api-2.1.1.jar

  • json-20240303.jar

  • keycloak-admin-client-26.0.4.jar

  • resteasy-client-6.2.11.Final.jar

  • resteasy-core-4.7.9.Final.jar

  • resteasy-jackson2-provider-4.7.9.Final.jar

  • resteasy-multipart-provider-6.2.11.Final.jar

  • wildfly-client-config-1.0.1.Final.jar

I suspect a conflict between jakarta.ws.rs and javax.ws.rs, but I am unsure how to resolve it.

How can I fix it?

Share Improve this question asked Jan 31 at 21:16 lalalala 1
Add a comment  | 

1 Answer 1

Reset to default 0

You’re using a mix of versions of RESTEasy, which you should not be doing. You're also including two different versions of the Jakarta REST API which are not compatible with each other.

For Keycloak 26, RESTEasy is longer used and Quarkst REST, formally RESTEasy Reactive, should be used. You'll need to migrate to using the new REST Client implementation.

As a simple breakdown for RESTEasy itself. RESTEasy 4.7 targets Jakarta REST 2.1. RESTEasy 6.2 targets Jakarta REST 3.1 and RESTEasy 7.0 targets Jakarta REST 4.0.

转载请注明原文地址:http://anycun.com/QandA/1744846226a88436.html