Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException: org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder

Tags:

trying to create a keycloak object to register new user with keycloak with following code:

 Keycloak keycloak = KeycloakBuilder.builder()
                            .serverUrl(serverUrl)
                            .realm(realm)
                            .grantType(OAuth2Constants.PASSWORD)
                            .clientId(clientId)
                            .clientSecret(clientSecret)
                            .username("someone")
                            .password("someword")
                            .build();

But get following error:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/jboss/resteasy/client/jaxrs/ResteasyClientBuilder] with root cause

java.lang.ClassNotFoundException: org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131] at org.keycloak.admin.client.Keycloak.(Keycloak.java:58) ~[keycloak-admin-client-4.3.0.Final.jar:4.3.0.Final] at org.keycloak.admin.client.KeycloakBuilder.build(KeycloakBuilder.java:147) ~[keycloak-admin-client-4.3.0.Final.jar:4.3.0.Final] at hello.GreetingController.greeting(GreetingController.java:100) ~[main/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]

like image 758
user840930 Avatar asked Sep 23 '18 12:09

user840930


1 Answers

Please try to add these dependencies to your project pom. Versions of dependencies could be 3.6.0.Final or 3.5.0.Final (i am not sure your keycloak-admin-client dependency version. But, i used keycloak-admin-client 3.0.0.Final with 3.5.0.Final resteasy-client. It works successfully.)

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson2-provider</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-multipart-provider</artifactId>
    </dependency>
like image 155
Batuhan Avatar answered Oct 06 '22 02:10

Batuhan