Open norricorp opened 4 years ago
Hi John, Can you try and follow the steps described there? http://www.janua.fr/keycloak-spi-adding-a-custom-event-listener-module/
This module was based on the sysout example, so this should work similarly.
So you used the jboss-cli.sh rather than the manual approach of copying files? But you still edited the standalone.xml file manually?
This is what I did
cd ~/SpringBoot/keycloak/keycloak-6.0.1
bin/jboss-cli.sh --command="module add --name=org.softwarefactory.keycloak.mqtt --resources=~/SpringBoot/keycloak-event-listener-mqtt/target/event-listener-mqtt-jar-with-dependencies.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-server-spi"
edit standalone/configuration/standalone.xml
<subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
<web-context>auth</web-context>
<providers>
<provider>classpath:${jboss.home.dir}/providers/*</provider>
<!-- this is the line I have added -->
<provider>module:org/softwarefactory/keycloak/mqtt</provider>
</providers>
and exaqctly the same problem
16:24:40,028 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "microprofile-metrics-smallrye")]): java.lang.NullPointerException at org.wildfly.extension.microprofile.metrics-smallrye@16.0.0.Final//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:86)
I am using keycloak 6.0.1. I have tried 7.0.0 and same problem. Running on mint linux 19.x
MQTTEventListenerProvider.java package org.softwarefactory.keycloak.providers.events.mqtt;
Copying event-listener-mqtt-jar-with-dependencies.jar to ${KEYCLOAK_HOME}/standalone/deployments is enough to get the listener available. You then have to activate it in the realm's events config page in the GUI.
I agree that should happen but it is not starting. The extra line in standalone.xml is preventing it from starting.
------ Original Message ------ From: "Matthieu Huin" notifications@github.com To: "mhuin/keycloak-event-listener-mqtt" keycloak-event-listener-mqtt@noreply.github.com Cc: "norricorp" john@norricorp.f9.co.uk; "Author" author@noreply.github.com Sent: 07/10/2019 17:14:12 Subject: Re: [mhuin/keycloak-event-listener-mqtt] updating standalone.xml causes keycloak not to start (#1)
Copying event-listener-mqtt-jar-with-dependencies.jar to ${KEYCLOAK_HOME}/standalone/deployments is enough to get the listener available. You then have to activate it in the realm's events config page in the GUI.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mhuin/keycloak-event-listener-mqtt/issues/1?email_source=notifications&email_token=AEUBLYOAYCYZMVLIFW3XSZDQNNN5JA5CNFSM4I4TWF62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAQ5XSY#issuecomment-539089867, or mute the thread https://github.com/notifications/unsubscribe-auth/AEUBLYPA2XW2U72RG5MEQALQNNN5JANCNFSM4I4TWF6Q.
I meant that you don't have to edit the standalone.xml file to make it work; putting the jar in the deployments directory is enough. I'll update the README with clearer installation instructions.
So having copied the module to modules via jboss-cli.sh, I then have under modules
org/softwarefactory/keycloak/mqtt/main: event-listener-mqtt-jar-with-dependencies.jar module.xml
where module.xml is
<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="org.softwarefactory.keycloak.mqtt">
<resources>
<resource-root
path="event-listener-mqtt-jar-with-dependencies.jar"/>
<dependencies>
<module name="org.keycloak.keycloak-core"/>
<module name="org.keycloak.keycloak-server-spi"/>
</dependencies>
standalone.xml is untouched as you suggested. Keycloak now starts.
I open a browser, log into keycloak and go to events. Under the events tab, the only two event listeners are jboss-logging and email (ie the defaults). There is no MQTT.
So I am not sure how you got this to work, especially as you said that you followed the instruction at janua.fr, which does include updating standalone.xml.
Regards, John
Sorry, as you can see the last changes to the code were from 6 months ago, and I didn't document my process at the time. It turns out the instructions on janua.fr didn't apply after all. If you follow the steps in the README (I just tested it myself and updated the README a few minutes ago) it should work as expected.
Looked thru' the readme. Do I still need to run jboss-cli.sh to copy the jar and create a module.xml?
no, running this is not needed.
well how will keycloak know where the jar is? Ah - under resource root. So still useful to put the jar within keycloak.
the standalone/deployments directory in keycloak's home is special, whatever gets added there is hot-deployed. You can make sure the dynamic loading worked by looking for a .deployed file with the jar name in that directory; or you can check keycloak's logs.
Matthieu, firstly sorry for the delay. I had a BSOD and had to move a load of VMs. So I did what was described in the readme file and now have a different problem which may be to do with the actual jar itself.
08:54:18,857 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "event-listener-mqtt-jar-with-dependencies.jar")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"event-listener-mqtt-jar-with-dependencies.jar\".STRUCTURE" => "WFLYSRV0153: Failed to process phase STRUCTURE of deployment \"event-listener-mqtt-jar-with-dependencies.jar\" Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYSRV0160: Failed to mount deployment content Caused by: java.util.zip.ZipException: zip END header not found"}}
Any ideas of the cause of this?
Keycloak does then run but I don't think it has loaded the mqtt jar. And going to the admin console, events, config, mqtt does not show up on the list event listeners, just the two defaults.
Mathhieu, I am giving up on this. Followed the instructions using keycloak 6.0.1 and just can't get it to work. More inportantly I am giving up on user registration within keycloak. I think it is badly thought out but will raise concerns on the mailing list.
Actually just found a event-listener-mqtt-jar-with-dependencies.jar.failed file which is created when the module is not loaded at startup. "{\"WFLYCTL0080: Failed services\" => {\"jboss.deployment.unit.\\"event-listener-mqtt-jar-with-dependencies.jar\\".STRUCTURE\" => \"WFLYSRV0153: Failed to process phase STRUCTURE of deployment \\"event-listener-mqtt-jar-with-dependencies.jar\\" Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYSRV0160: Failed to mount deployment content Caused by: java.util.zip.ZipException: zip END header not found\"}}"
Is the jar corrupted? There were no errors during build.
I have compiled the code and copied jar to modules/org/soft/key/prov*/events/mqtt/main and created module.xml as docs in 6.2.2 of the Server Developer docs
Then updated standalone.xml
Running standalone.sh -b 0.0.0.0 gives
.war (runtime-name: keycloak-server.war) in 255ms 09:43:01,955 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "microprofile-metrics-smallrye")]): java.lang.NullPointerException at org.wildfly.extension.microprofile.metrics-smallrye@16.0.0.Final//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:86) at org.jboss.as.controller@8.0.0.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999) ......
Removing the additional line and all is well. Assuming there is no daft error in the xml, then would the problem be that the system finds the generated jar and reacts badly to that?
But having said that, the error complains about microprofile-metrics-smallrye:2.0, so should that be commented out? I also saw this https://developer.jboss.org/thread/280621.
Regards, John