Closed wwwdavid34 closed 3 years ago
I do not see that in the current file list, can you tell me where to fine them?
OK, I think I have to create the jar files from the two .java files in the collection.
You have the choice either to built it yourself using
mvn clean package
or download pre-build ones on tag - v1.0.0.
@Selast Thank you for the reply. Another question, I do not find providers directory in my Keycloak 11.0.2. I noticed Keycloak.x do have a provider directory, is that what this plugin is meant to be used?
You're welcome. Keycloak uses all what you're gonna put inside $JBOSS_HOME/providers
as provider. It's at the same level as /themes
for example. That folder effectively doesn't exist per default.
Fiind more info here https://stackoverflow.com/a/59777742/7748446
Great! This is very helpful.
So I added a spi block in $JBOSS_HOME/standalone/configuration/standalone.xml. I used my mailchimp API_KEY, and AUDIENCE_ID for LIST_ID for I do not find LIST_ID in my mail chimp account and AUDIENCE_ID is the closest I can find.
Then I placed keycloak-mailchimp-1.0.0-jar-with-dependencies.jar under $JBOSS_HOME/providers.
Now, if I restart the service, how should I know the new plugin is working?
Simple. Just open your Keycloak at http://$keycloak:$port/auth/admin/master/console/#/server-info/providers
and just ctlr
+ f
and inside the list, you'll find mailchimp
somewhere, in the block of eventsListener
, as this plugin implements the events Listener of keycloak.
Hmm... I cannot find mailchimp in the eventsListenter list. Also I do not find any related errors in the Keycloak startup log. Is there any way I can debug where went wrong?
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /home/fengchihsu/keycloak/keycloak-11.0.2
JAVA: java
JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
=========================================================================
17:18:57,312 INFO [org.jboss.modules] (main) JBoss Modules version 1.10.1.Final
17:18:57,879 INFO [org.jboss.msc] (main) JBoss MSC version 1.4.11.Final
17:18:57,892 INFO [org.jboss.threads] (main) JBoss Threads version 2.3.3.Final
17:18:58,062 INFO [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: Keycloak 11.0.2 (WildFly Core 12.0.3.Final) starting
17:18:59,493 INFO [org.wildfly.security] (ServerService Thread Pool -- 18) ELY00001: WildFly Elytron version 1.12.1.Final
17:19:00,577 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
17:19:00,664 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 27) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
17:19:00,953 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
17:19:00,988 INFO [org.xnio] (MSC service thread 1-4) XNIO version 3.8.1.Final
17:19:01,033 INFO [org.xnio.nio] (MSC service thread 1-4) XNIO NIO Implementation Version 3.8.1.Final
17:19:01,171 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 49) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
17:19:01,175 INFO [org.jboss.as.security] (ServerService Thread Pool -- 48) WFLYSEC0002: Activating Security Subsystem
17:19:01,163 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 37) WFLYCLINF0001: Activating Infinispan subsystem.
17:19:01,176 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 43) WFLYNAM0001: Activating Naming Subsystem
17:19:01,294 INFO [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 51) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
17:19:01,328 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 36) WFLYIO001: Worker 'default' has auto-configured to 4 IO threads with 32 max task threads based on your 2 available processors
17:19:01,338 INFO [org.jboss.as.jaxrs] (ServerService Thread Pool -- 38) WFLYRS0016: RESTEasy version 3.12.1.Final
17:19:01,357 INFO [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 52) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
17:19:01,361 INFO [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=5.0.3.Final-redhat-00005
17:19:01,368 INFO [org.wildfly.extension.microprofile.metrics.smallrye] (ServerService Thread Pool -- 53) WFLYMETRICS0001: Activating Eclipse MicroProfile Metrics Subsystem
17:19:01,492 INFO [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 5.0.18.Final
17:19:01,527 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 32) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
17:19:01,659 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 2.1.3.Final starting
17:19:01,665 WARN [org.wildfly.clustering.web.undertow] (ServerService Thread Pool -- 54) WFLYCLWEBUT0007: No routing provider found for default-server; using legacy provider based on static configuration
17:19:01,680 INFO [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.22.Final)
17:19:01,733 INFO [org.jboss.as.naming] (MSC service thread 1-3) WFLYNAM0003: Starting Naming Service
17:19:01,851 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = h2
17:19:01,854 INFO [org.jboss.as.mail.extension] (MSC service thread 1-2) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
17:19:01,957 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 54) WFLYUT0014: Creating file handler for path '/home/fengchihsu/keycloak/keycloak-11.0.2/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
17:19:02,244 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 8 (per class), which is derived from the number of CPUs on this host.
17:19:02,244 INFO [org.jboss.as.ejb3] (MSC service thread 1-4) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 32 (per class), which is derived from thread worker pool sizing.
17:19:02,294 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0012: Started server default-server.
17:19:02,340 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0018: Host default-host starting
17:19:02,645 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:80
17:19:02,751 INFO [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0493: EJB subsystem suspension complete
17:19:02,920 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0001: Bound data source [java:jboss/datasources/KeycloakDS]
17:19:02,930 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
17:19:03,072 INFO [org.jboss.as.patching] (MSC service thread 1-2) WFLYPAT0050: Keycloak cumulative patch ID is: base, one-off patches include: none
17:19:03,168 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) WFLYDS0013: Started FileSystemDeploymentService for directory /home/fengchihsu/keycloak/keycloak-11.0.2/standalone/deployments
17:19:03,201 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "keycloak-server.war" (runtime-name: "keycloak-server.war")
17:19:04,532 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:443
17:19:04,892 INFO [org.infinispan.PERSISTENCE] (MSC service thread 1-1) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.marshalling.jboss.JBossMarshaller'
17:19:04,894 INFO [org.infinispan.PERSISTENCE] (MSC service thread 1-4) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.marshalling.jboss.JBossMarshaller'
17:19:04,932 INFO [org.infinispan.CONTAINER] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Turia' 10.1.8.Final
17:19:05,377 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 56) WFLYCLINF0002: Started client-mappings cache from ejb container
17:19:05,445 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 63) WFLYCLINF0002: Started authenticationSessions cache from keycloak container
17:19:05,453 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 60) WFLYCLINF0002: Started loginFailures cache from keycloak container
17:19:05,443 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0002: Started clientSessions cache from keycloak container
17:19:05,445 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 66) WFLYCLINF0002: Started actionTokens cache from keycloak container
17:19:05,459 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 61) WFLYCLINF0002: Started work cache from keycloak container
17:19:05,459 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 58) WFLYCLINF0002: Started sessions cache from keycloak container
17:19:05,461 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 57) WFLYCLINF0002: Started offlineClientSessions cache from keycloak container
17:19:05,466 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 64) WFLYCLINF0002: Started offlineSessions cache from keycloak container
17:19:05,528 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 65) WFLYCLINF0002: Started keys cache from keycloak container
17:19:05,529 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 67) WFLYCLINF0002: Started realms cache from keycloak container
17:19:05,531 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 68) WFLYCLINF0002: Started users cache from keycloak container
17:19:05,530 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 59) WFLYCLINF0002: Started authorization cache from keycloak container
17:19:05,722 WARN [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0273: Excluded subsystem webservices via jboss-deployment-structure.xml does not exist.
17:19:06,827 INFO [org.keycloak.services] (ServerService Thread Pool -- 64) KC-SERVICES0001: Loading config from standalone.xml or domain.xml
17:19:07,336 INFO [org.keycloak.url.DefaultHostnameProviderFactory] (ServerService Thread Pool -- 64) Frontend:
Did you added the two jar files?
Take a look here https://github.com/bayamsell/keycloak-mailchimp/releases
One contains the code, the other (obviously) contains dependencies.
I've release a new version which should help you deploy using docker. I may perhaps also release an image on Docker for this if you are interested.
@Selast Good point, I only copied the dependencies.jar thinking it has everything packed. I now have both jars from v1.0.1 into the providers directory. This time the start sequence ran into errors.
This is the first error message in the log. I suppose I need to compile jar files from the source?
tarted authorization cache from keycloak container 08:46:33,643 WARN [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0273: Excluded subsyst em webservices via jboss-deployment-structure.xml does not exist. 08:46:34,642 INFO [org.keycloak.services] (ServerService Thread Pool -- 56) KC-SERVICES0001: Loading conf ig from standalone.xml or domain.xml 08:46:34,943 FATAL [org.keycloak.services] (ServerService Thread Pool -- 56) Error during startup: java.la ng.UnsupportedClassVersionError: com/bayamsell/keycloak/MailChimpListenerProviderFactory has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I suppose you're using this locally and you have java 8 installed. These jars are compiled using java 11, reason while it's throwing
has been compiled by a more recent version of the Java Runtime
.
Now, either you update to minimum java 8 or you use docker.
Thanks! That did the trick!
Now I just need to understand how this plugin works...
@Selast Please correct me if I am wrong. Once the plugin is in place and activated (as seen in the provider as a eventsListener), any change add/delete in the Users list will be reflected to the subscriber list in Mailchimp audience. Is that correct?
If so, how does this plugin differs between different realms in Keycloak?
You're right. In this plugin, the way it is, no information about the realm is setup, so it just takes all events from realms indem it's installed. Now to make it more open to multiple realms, I still don't jave a good idea. These are the mani two ideas that I have in mind to do it:
What idea do you thing would be more interesting?
I am new to Mailchimp, still figuring out how everything works there. But I agree with you that it is not feasible for the given project scope. I do like the second option to have a GUI for configuring the plugin, so that each realm (or even client?) can have a separate combination of API_KEY and LIST_ID configured that interreacts with different audience list on Mailchimp.
Now, I have tried to add user in Users list in Keycloak, but the subscriber list in Mailchimp does not seem to reflect the change. Is there anywhere I can debug this? How long does it usually take for the change in Keycloak to be synced to Mailchimp?
Doing it in the keycloak's plugin seem then more feasable as on the side of mailchimp. I'll dig into that idea a bit more.
For your problem concerning the mailchimp event listener not being triggered, open your keycloak at at
/auth/admin/master/console/#/realms/mifa/events-settings
and in the field Event Listeners
, click and choose mailchimp
.
Oh, I didn't know that need to be changed. I added mailchimp in the Event Listeners, and poped out a warning saying "Unexpected server error has occurred."
Here is the error log right after the server successfully started. It seems the error is raised during connecting to Mailchimp with given API_KEY and LIST_ID. I double checked my API_KEY and LIST_ID are correct. Can you read more clues from the error log?
13:38:25,159 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://0.0.0.0:9990
13:38:43,215 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-5) Uncaught server error: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.github.alexanderwe.bananaj.connection.Connection.
Ok, I'll check this
@Selast If you have code in debugging mode I am more than happy to test it in my environment.
Now I understand the problem. The fact is that the banana-j library is using a sub-library that is not imported in the runtime.
Anyway, this should be fixed right away. Concerning any dev code, I don‘t have, all what‘s in this repository is my actual dev and working code
Thanks for spotting the problem. Sounds like the second option is a quick and sure fix to be distributed as binaries.
I will test the new release as soon as it's ready.
Right 😂? I‘m on it. I‘ll publish the newer version here once it‘s tested.
So the second solution was then applied and released under version v1.0.2. Also, there is a Dev.Dockerfile
to use locally after building using mvn clean package
.
That worked beautifully! I was able to register a new user from the login page and it also pop up in Mailchimp. However, when I add a new user in admin console in Keycloak, that does not seem to trigger the plugin. Guess the user creation event is defined differently?
Did you checked inside mailchimp?
After some more tests, here is my observation on how the plugin works.
Thanks for testing this through and through. I'm excited to bring up solutions to these points.
Could you please open new issues for each of these remarks and close this issue? I'll structure my time to implement them.
My pleasure. :)
I do not see that in the current file list, can you tell me where to fine them?