Creating an AnnotationBasedEventListner for Crowd seems to be really well documented here:
http://confluence.atlassian.com/display/CROWDDEV/Event+Listeners
but after a couple of hours I simply cannot get Crowd to see the listener.
I've actually copied the code verbatim for the atlassian-plugin.xml file and the basic UserCreatedListener class example verbatim aside from changing the package name.
Here are the two files - really simple. Any guidance tips or especially working code with Crowd 2.2.7+ would be hugely appreciated!
What would be most useful would be a working code snippet.
Here is the error:
2011-06-09 10:16:25,200 main INFO [atlassian.plugin.loaders.ScanningPluginLoader] Plugin Unit: /Users/brendan/Desktop/java/crowd-home-2.2.7/plugins/AddUserToLdapPlugin-1.0.jar (1307636154000) created 2011-06-09 10:16:25,204 main INFO [atlassian.plugin.manager.DefaultPluginManager] Updating plugin 'crowd.listeners.core:1.0' to 'crowd.listeners.core:1.0' 2011-06-09 10:16:25,211 main ERROR [atlassian.event.internal.EventPublisherImpl] There was an exception thrown trying to dispatch event 'com.atlassian.config.lifecycle.events.ApplicationStartedEvent@54856d00' from the invoker 'com.atlassian.event.internal.SingleParameterMethodListenerInvoker@27cc75cb'. java.lang.RuntimeException: Error initialising plugin manager: Duplicate plugin found (installed version is the same or older) and could not be unloaded: 'crowd.listeners.core' at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54)
The code:
package com.xyz.crowd.plugins; import com.atlassian.crowd.event.user.UserCreatedEvent; public class UserCreatedListener { @com.atlassian.event.api.EventListener public void printUserCreatedEvent(UserCreatedEvent event) { System.out.println("User " + event.getUser().getDisplayName() + " has been created."); } }
-------------
<atlassian-plugin name="Example Listeners" key="crowd.listeners.core" system="false"><plugin-info><description>This contains example listeners</description><vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/><version>1.0</version></plugin-info><listener name="User Created Listener" key="usercreatedlistener" class="com.xyz.crowd.plugins.UserCreatedListener"><description>Will listen for user creation events.</description></listener></atlassian-plugin>
Community moderators have prevented the ability to post new answers.
The example atlassian-plugin.xml in http://confluence.atlassian.com/display/CROWDDEV/Event+Listeners had atlassian-plugin key attribute set to "crowd.listeners.core" which is used by Crowd, and seems to have caused the duplicate plugin error that you encountered. I fixed the page, and your listener should start working after you change the atlassian-plugin key attribute in atlassian-plugin.xml to something unique like "example.listeners".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.