KeyCloak custom REST Endpoint - Admin client classes not found

I have implemented a custom REST endpoint in KeyCloak 9.0.3. This endpoint will be invoked by an external UI layer to complete the entire registration flow including creating the user and sending the verification flow. In the SPI code, I am invoking the Admin REST client to create the user and send the verification email. I get an error when I invoke this service.

ERROR [] (default task-42) Uncaught server error: java.lang.NoClassDefFoundError: org/keycloak/admin/client/KeycloakBuilder

My POM file has the dependency included -


I have tried adding a provided depenency as well but no luck.
Any ideas on what I am missing here? Or is there a problem with accessing the Admin REST API from within a custom SPI?

1 Like

It’s possible you need to add this to your jboss-deployment-structure.xml file.
An example can be found here for such a file, take note of the location of the file also.

In your case you’ll probably need to add

<module name="org.keycloak.keycloak-admin-client" />

Not tried it though but I expect this will solve your problem, let us know how it went

Thanks but now I get a …

Caused by: org.jboss.modules.ModuleNotFoundException: org.keycloak.keycloak-admin-client
at org.jboss.modules.Module.addPaths(
at org.jboss.modules.Module.relinkIfNecessary(
at org.jboss.modules.ModuleLoader.loadModule(
at org.jboss.modules.ModuleLoader.loadModule(


@sab.surendran I am getting the same error. Did you solved the issue?

I may be incorrect, but I don’t think the keycloak-admin-client is available as a module in the standard Keycloak server. You’d have to put the keycloak-admin-client jar file into your ear file at the top level, and put it in your META-INF/application.xml as a java module.

Let me know if there’s anything I can do to help with this!

Hi… That is correct. I was able to resolve it using the admin client as a module.
Add the admin client to the modules directory inside KeyCloak.
And I added a META-INF\services\jboss-deployment-structure.xml to my custom provider jar.

 <?xml version="1.0" encoding="UTF-8"?>
             <module name="org.keycloak.keycloak-admin-client" />

I am stuck at the same place! Can you suggest how you added keycloak-admin-client as a module? Also for adding the said module is any jar downloaded?

Romil Shah

This might be a bad method. But I copied the keycloak-admin-client.xx.x.x.jar and module.xml into

keycloak-admin-client.xx.x.x.jar can download from

and contents of the modile.xml like this,

<?xml version="1.0" encoding="UTF-8"?>
  ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
  ~ and other contributors as indicated by the @author tags.
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
<module name="org.keycloak.keycloak-admin-client" xmlns="urn:jboss:module:1.3">
        <resource-root path="keycloak-admin-client-xx.x.x.jar"/>

		<module name="org.keycloak.keycloak-common" />
         <module name="org.keycloak.keycloak-core"/>
		<module name="org.jboss.resteasy.resteasy-jaxrs"/>
		<module name=""/>
         <module name="javax.api"/>
        <module name="javax.api"/>
        <module name="javax.activation.api"/>
        <module name="sun.jdk" optional="true"/>

Then restart the keycloak server.

1 Like