Event listener tutorial for atlassian-event library does not work with JIRA 4.4

Chris Johnson October 26, 2011

I was trying to follow the example given at https://developer.atlassian.com/display/DOCS/Plugin+Tutorial+-+Writing+event+listeners+with+the+atlassian-event+library on writing event listeners using the atlassian-event library, to update an existing working JIRA event listener I had written. The existing listener uses very deprecated classes and methods, and does not self-install via the UPM. So it seemed like a great idea to update it to use this library and make it a plugin.

However, I had trouble getting it to work. So much so that I finally just downloaded the entire example tutorial listener from Bitbucket and compiled it. The tutorial does not work with JIRA 4.4 either! In fact, it appears the constructor never even gets called. It does work perfectly when i compile it for JIRA 4.3.

I have not been able to find any documentation on what changed between 4.3 and 4.4 that is causing this failure. Can someone point me at the appropriate documentation, or can the tutorial be updated to work with 4.4, please?

6 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Tapas Mondal November 13, 2012

when I am going to register this in Listener getting error:

Class [com.example.tutorial.plugins.IssueCreatedResolvedListener] is not of type JiraListener.

0 votes
Onder Yesil February 18, 2013

I added some print outs (see below), but it does not work. I see nothing on the catalina.out. it looks like the plugin is not loaded the JIRA and @EventListener does not work.

@Override
public void afterPropertiesSet() throws Exception {

eventPublisher.register( this);

System.out.println("REGISTERED");

}

/**

* Called when the plugin is being disabled or removed.

*

@throws

Exception

*/

@Override publicvoid destroy() throws Exception {
eventPublisher.unregister( this);

System.out.println("DESTROYED");

}

Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2013

Here is my working plugin.xml component delcaration for a 5.x listener:

<component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"/>

<component key="eventListener" name="JEMH Issue Event Listener" class="com.javahollic.jira.emh.service.listener.JEMHIssueEventListener"> </component>

Then, my listener class is declared as:

public class JEMHIssueEventListener implements InitializingBean, DisposableBean

Within the listener (constructor wired) I have:

@Override

public void afterPropertiesSet() throws Exception

{

fEventPublisher.register(this);

}

And:

@Override

public void destroy() throws Exception

{

fEventPublisher.unregister(this);

}

And of course:

@EventListener

public void onIssueEvent(IssueEvent issueEvent)

{

So. with the stubs above, you ought to get a plugin deployed and a the listener invoked. If you are not able to do this, you should check the status of the deployment.

Onder Yesil February 18, 2013

thank you Andy,

i have same code. : https://answers.atlassian.com/questions/138943/my-eventlistener-not-called

but i get nothing see on the catalina.out or on logs.

Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2013

increase your logging level via JIRA Admin > Logging and Profiling. When you deploy, there is traffic, look for stack traces...

tommy guo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 12, 2013

Andy I have the same code and I've turned on all logging capabilities on JIRA but I'm still not seeing any output from my event lsitener. Do you have any ideas as to why this is happening or how I can resolve it? Any help would be greatly appreciated!

0 votes
Onder Yesil February 18, 2013

I have same problem. do somebody have jiraListener example for jira 5.

0 votes
Tapas Mondal November 13, 2012

is your plugin will generated event if I create an Issue using Import?

0 votes
Akeles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2012

Hi,

I have verified that the tutorial is working correctly on JIRA 4.4.1

Chris Johnson May 8, 2012

We are running JIRA 5 now and I've refactored my plugin to use that. I'm going to guess that the problem may have been a particular version of the SDK, as I've encountered problems of that nature subsequently.

Tapas Mondal November 13, 2012

is your plugin will generated event if I create an Issue using Import?

0 votes
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 26, 2011

I dont have time to do the tutorial but Ive looked at it and seems to match what I have. Listeners do work in 4.4, I use it for bi-directional between JIRA and Brightidea (plugin page), in a nutshell.

  1. Install plugin SDK
  2. atlas-create-jira-plugin

There isnt a 'Listener' module type so you cant use 'atlas-create-jira-plugin-module'. You have to create a component entry in your atlassian-plugin.xml, like:

<component key="eventListener" class="com.javahollic.SomeIssueListener"/>

The related code is pretty much whats presented on https://developer.atlassian.com/display/DOCS/Plugin+Tutorial+-+Writing+event+listeners+with+the+atlassian-event+library#PluginTutorial-Writingeventlistenerswiththeatlassian-eventlibrary-lifecycle.

If you've deployed your plugin, did it deploy, are there logs indicating a problem? Have you tried a remote socket attach debug against JIRA?

Chris Johnson November 10, 2011

Yes, the plugin deployed. However, a log message I try to issue in the constructor never appears -- as if the constructor were never called.

I've been able to recompile my custom-written listener developed for 4.3 against 4.4 using the updated SDK atlas tools, so I haven't spent much more time on doing it the "right way" as a plugin yet.

But as I mentioned in my original posting, I merely took the entire example code for the tutorial from the Atlassian repository and compiled it according to the tutorial instructions. Except for subsequently adding log calls in an effort to debug it, I otherwise did not alter the code or the XML. Hence, if the code or XML were wrong, the example itself is wrong, since that is what I was using.

As to the specifics of the component key, etc., here is the atlassian-plugin.xml in its entirety:

&lt;atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"&gt;
    &lt;plugin-info&gt;
        &lt;description&gt;${project.description}&lt;/description&gt;
        &lt;version&gt;${project.version}&lt;/version&gt;
        &lt;vendor name="${project.organization.name}" url="${project.organization.url}" /&gt;
    &lt;/plugin-info&gt;

    &lt;component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"&gt;
        &lt;description&gt;atlassian-event EventPublisher imported from system bundle.&lt;/description&gt;
    &lt;/component-import&gt;

    &lt;component key="eventListener" class="com.example.tutorial.plugins.IssueCreatedResolvedListener"&gt;
        &lt;description&gt;Class that processes the incoming JIRA issue events.&lt;/description&gt;
    &lt;/component&gt;

&lt;/atlassian-plugin&gt;

I have not tried a remote socket attach debug against JIRA -- yet.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events