Hi,
I'm trying to run the example of a Crowd plugin with Event Listeners but it does not work.
I see differences between the official documentation and the repository example. For example, in the repository there is no listener section in atlassian-plugin.xml.
I have replaced the "System.out.println" line with a slf4j logger, but it also does not print any logs when a user is created.
If I add the listener section in atlassian-plugin.xml, when I launch Crowd it returns an error of ClassNotFoundException:
2022-06-16 09:48:53,336 localhost-startStop-1 ERROR [atlassian.plugin.manager.DefaultPluginManager] There was an error loading the descriptor 'User Created Listener' of plugin 'com.atlassian.crowd.example.crowd-event-listener-example'. Disabling.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.atlassian.crowd.event.listener.example.UserCreatedListener': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.atlassian.crowd.event.listener.example.UserCreatedListener] from ClassLoader [com.atlassian.crowd.example.crowd-event-listener-example [28]]
at com.atlassian.crowd.console.listener.StartupListener.contextInitialized(StartupListener.java:101)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4705)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.atlassian.crowd.event.listener.example.UserCreatedListener] from ClassLoader [com.atlassian.crowd.example.crowd-event-listener-example [28]]
Caused by: java.lang.ClassNotFoundException: com.atlassian.crowd.event.user.UserCreatedEvent not found by com.atlassian.crowd.example.crowd-event-listener-example [28]
This is the source code (without the listener section):
UserCreatedListener.java
package com.atlassian.crowd.event.listener.example;
import com.atlassian.crowd.event.user.UserCreatedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UserCreatedListener{
private static final Logger log = LoggerFactory.getLogger(UserCreatedListener.class);
@com.atlassian.event.api.EventListener
public void printUserCreatedEvent(UserCreatedEvent event) {
log.debug("User " + event.getUser().getDisplayName() + " has been created.");
}
}
atlassian-plugin.xml
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
</plugin-info>
</atlassian-plugin>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atlassian.crowd.event.listener.example</groupId>
<artifactId>crowd-event-listener-example</artifactId>
<version>1.0.1-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>event-listener-example</name>
<description>This is an event listener plugin for Atlassian Crowd.</description>
<packaging>atlassian-plugin</packaging>
<repositories>
<repository>
<id>atlassian-public</id>
<url>https://packages.atlassian.com/mvn/maven-external/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://packages.atlassian.com/mvn/maven-external/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.atlassian.crowd</groupId>
<artifactId>crowd-events</artifactId>
<version>${crowd.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.event</groupId>
<artifactId>atlassian-event</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>crowd-maven-plugin</artifactId>
<version>8.2.3</version>
<extensions>true</extensions>
<configuration>
<productVersion>${crowd.version}</productVersion>
<productDataVersion>${crowd.data.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<instructions>
<Import-Package>
com.atlassian.event.*
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<crowd.version>4.3.5</crowd.version>
<crowd.data.version>4.1.10</crowd.data.version>
</properties>
</project>
Thanks!
@CARLOS MEDINA SANCHEZ Did you resolve your issue? I'm running into the same problem myself. I cannot get the example to build, even with attempting to use some of the hacks provided.
When I add in the listener to the atlassian-plugin.xml I immediately get crashes like you do.
All I did was clone the example package, add the listeners to the atlassian-plugin.xml, added logging to my source files and then ran "atlas-package"
@CARLOS MEDINA SANCHEZ I solved my issue. borrowing some code from other working examples, I found I had to include the below information into the POM.XML
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>crowd-maven-plugin</artifactId>
<version>8.2.3</version>
<!-- <version>8.4.2</version> -->
<extensions>true</extensions>
<configuration>
<productVersion>${crowd.version}</productVersion>
<productDataVersion>${crowd.data.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<instructions>
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*;resolution:="optional",
com.atlassian.event.*
</Import-Package>
</instructions>
</configuration>
</plugin>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @CARLOS MEDINA SANCHEZ and welcome to the community!
I tried to download and run this example and have same problem as you have: ClassNotFoundException, when I was running my Crowd.
I can describe my way to solve this issue:
1) I created my custom crowd plugin with command:
atlas-create-crowd-plugin
2) Then I updated my atlas-create-crowd-plugin-module. That will allow you to use Crowd 4.4.
AMPS_PLUGIN_VERSION="8.5.0"
3) I added UserCreatedListener class and dependencies to newly created project.
Also you can use different log levels. Other way to enable DEBUG level use this how to. Just for fun I enabled them all:
System.out.println("User " + event.getUser().getDisplayName() + " has been created.");
log.info("User " + event.getUser().getDisplayName() + " has been created.");
log.warn("User " + event.getUser().getDisplayName() + " has been created.");
log.debug("User " + event.getUser().getDisplayName() + " has been created.");
log.error("User " + event.getUser().getDisplayName() + " has been created.");
4) Then I used this command to run Crowd 4.4 with my plugin.
mvn crowd:run
And after I created user I had this message in logs:
I hope this small guide will help you to resolve the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
upd:
You can find atlas-create-crowd-plugin-module file in your atlassian-plugin-sdk folder. For me it was:
/usr/local/Cellar/atlassian-plugin-sdk/8.2.7/libexec/bin/atlas-create-crowd-plugin-module
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have the same problem, after upgrading AMPS version to 8.5.0 I've got following error:
ERROR] Failed to execute goal com.atlassian.maven.plugins:crowd-maven-plugin:8.5.0:generate-rest-docs (default-gen
erate-rest-docs) on project ntp-login-plugin: Execution default-generate-rest-docs of goal com.atlassian.maven.plug
ins:crowd-maven-plugin:8.5.0:generate-rest-docs failed: An API incompatibility was encountered while executing com.
atlassian.maven.plugins:crowd-maven-plugin:8.5.0:generate-rest-docs: java.lang.NoSuchMethodError: 'java.lang.Object
org.codehaus.plexus.util.xml.Xpp3Dom.getInputLocation()'
[ERROR] -----------------------------------------------------
[ERROR] realm = extension>com.atlassian.maven.plugins:crowd-maven-plugin:8.5.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/userName/.m2/repository/com/atlassian/maven/plugins/crowd-maven-plugin/8.5.0/cro
wd-maven-plugin-8.5.0.jar
[ERROR] urls[1] = file:/C:/Users/userName/.m2/repository/com/atlassian/maven/archetypes/crowd-plugin-archetype/8.
5.0/crowd-plugin-archetype-8.5.0.jar
[ERROR] urls[2] = file:/C:/Users/userName/.m2/repository/com/atlassian/maven/plugins/amps-maven-plugin/8.5.0/amps
-maven-plugin-8.5.0.jar
[ERROR] urls[3] = file:/C:/Users/userName/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar
[ERROR] urls[4] = file:/C:/Users/userName/.m2/repository/dom4j/dom4j/1.6.1-atlassian-3/dom4j-1.6.1-atlassian-3.ja
r
[ERROR] urls[5] = file:/C:/Users/userName/.m2/repository/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar
[ERROR] urls[6] = file:/C:/Users/userName/.m2/repository/biz/aQute/bnd/biz.aQute.bndlib/5.3.0/biz.aQute.bndlib-5.
3.0.jar
....
Does anyone have the same problem and know the resolution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.