deploying EventListenerProviderFactory to keycloak

810 views
Skip to first unread message

Fred Hauschel

unread,
Feb 12, 2021, 9:40:01 AM2/12/21
to Keycloak User

Hi there,
i try to add a simple EventListenerProvider to the keycloak docker image.

In the root of my jar there is a File "org.keycloak.events.EventListenerProviderFactory" with the content: my.packag.MyEventListenerProviderFactory

In the jar there is also the implementation of MyEventListenerProvider & MyEventListenerProviderFactory.

the dockerfile:
FROM jboss/keycloak

COPY register-account-listener/target/*.jar /opt/jboss/keycloak/modules/registration-listener/my/packag/provider/main
COPY register-account-listener/target/classes/module.xml /opt/jboss/keycloak/modules/registration-listener/my/packag/provider/main
COPY register-account-listener/target/classes/standalone.xml /opt/jboss/keycloak/standalone/configuration/standalone.xml

I've not really an idea how to add the module to the standalone.xml. I got the original standalone.xml from the keycloak distribution and add:

module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="my.packag">
    <resources>
        <resource-root path="SPI-registration-listener-0.1-SNAPSHOT.jar"/>
    </resources>
    <dependencies>
        <module name="org.keycloak.keycloak-core"/>
        <module name="org.keycloak.keycloak-server-spi"/>
        <module name="org.keycloak.keycloak-server-spi-private"/>
    </dependencies>
</module>


The container starts, but nothing happens ;-(


what did i miss?

Thanks

Garth

unread,
Feb 12, 2021, 10:24:10 AM2/12/21
to Fred Hauschel, 'Thomas Darimont' via Keycloak User
It should be in `META-INF/services/org.keycloak.events.EventListenerProviderFactory` rather than the root of the jar.
> --
> You received this message because you are subscribed to the Google
> Groups "Keycloak User" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to keycloak-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/keycloak-user/1dd69a87-1634-4c67-a5ef-55f26d71f495n%40googlegroups.com <https://groups.google.com/d/msgid/keycloak-user/1dd69a87-1634-4c67-a5ef-55f26d71f495n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Thomas Darimont

unread,
Feb 12, 2021, 10:24:21 AM2/12/21
to Fred Hauschel, Keycloak User
Hello Fred,

there are multiple ways to deploy custom extensions to keycloak.

Seems like you deployed your extension as a wildfly module. Does your jar have a META-INF/services/org.keycloak.events.EventsListenerProvider with the FQCN of your factory class?

I personally prefer to deploy simple .jar or .ear files into the standalone/deployments folder.


If you deploy your extension that keycloak should print some log entries of it registers the extension. Also don't forget to enable the event listener in the admin-console via realm settings -> events -> config.

Cheers,
Thomas

--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.

Thomas Darimont

unread,
Feb 12, 2021, 10:26:15 AM2/12/21
to Garth, Fred Hauschel, 'Thomas Darimont' via Keycloak User
Yep that's right, META-INF/services/org.keycloak.events.EventListenerProviderFactory 

Typed this on the go :D

Thanks for correcting :)

Reply all
Reply to author
Forward
Message has been deleted
0 new messages