Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

my EventListener not called

Onder Yesil February 18, 2013

atlassian-plugin.xml excerpt:

<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>

	<Export-Package>
		com.example.tutorial.plugins.IssueCreatedResolvedListener
	</Export-Package>

    <component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher">
        <description>atlassian-event EventPublisher imported from system bundle.</description>
    </component-import>

    <component key="eventListener" class="com.example.tutorial.plugins.IssueCreatedResolvedListener">
        <description>Class that processes the incoming JIRA issue events.</description>
    </component>

</atlassian-plugin>

IssueCreatedResolvedListener.java

package com.example.tutorial.plugins;

import java.util.logging.Logger;

import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.event.DraftWorkflowCreatedEvent;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
/**
* Simple JIRA listener using the atlassian-event library and demonstrating
* plugin lifecycle integration.
*/
public class IssueCreatedResolvedListener implements InitializingBean, DisposableBean {

public static final Logger log =
Logger.getLogger(IssueCreatedResolvedListener.class.getCanonicalName());
private final EventPublisher eventPublisher;

/**
* Constructor.
* @param eventPublisher injected @code">{@code EventPublisher} implementation.
*/
public IssueCreatedResolvedListener(EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}

/**
* Called when the plugin has been enabled.
* @throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
// register ourselves with the EventPublisher
eventPublisher.register(this);
}

/**
* Called when the plugin is being disabled or removed.
* @throws Exception
*/
@Override
public void destroy() throws Exception {
// unregister ourselves with the EventPublisher
eventPublisher.unregister(this);
}

/**
* Receives any @code">{@code IssueEvent}s sent by JIRA.
* @param issueEvent the IssueEvent passed to us
*/
@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
Long eventTypeId = issueEvent.getEventTypeId();
Issue issue = issueEvent.getIssue();

System.out.println("START onIssueEvent");

// if it's an event we're interested in, log it
if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
//log.info("Issue {} has been created at {}.", issue.getKey(), issue.getCreated());
System.out.println("ISSUE_CREATED_ID");
} else if (eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)) {
//log.info("Issue {} has been resolved at {}.", issue.getKey(), issue.getResolutionDate());
System.out.println("HALLOOO DAAAAAAAAAAAAR ISSUE_RESOLVED_ID");
}else if (eventTypeId.equals(EventType.ISSUE_UPDATED_ID)) {
//log.info("Issue {} has been resolved at {}.", issue.getKey(), issue.getResolutionDate());
System.out.println("ISSUE_UPDATED_ID");
}else if (eventTypeId.equals(EventType.ISSUE_DELETED_ID))
{ log.info("Delete issue event detected.");
System.out.println(".IS DELETED");
}
}


}

The plugin installs and is enabled without errors in the logs. But the messages are never printed.

What's wrong with the code?

I use JIRA 5.1.8.

Thanks in advance,

Önder

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
SteveW July 24, 2013

Not sure what the specific issue here is, but I've just updated this tutorial to JIRA 6.0.4. Along with the update, I tried to clarify and correct a few steps in the process, which may be of help....

See it here: https://developer.atlassian.com/display/JIRADEV/Writing+JIRA+Event+Listeners+with+the+atlassian-event+Library

0 votes
Onder Yesil February 18, 2013

Anyone ?????

Please !!!!!!!!

0 votes
Jobin Kuruvilla [Adaptavist]
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

Which logs are you checking? SOPs will come only in catalina.out.

Onder Yesil February 18, 2013

i check catalina.out and commandpromt where System.out.println should be printed. but i see nothing.

Jobin Kuruvilla [Adaptavist]
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

worth a shot ;) Code looks fine to me!

Onder Yesil February 18, 2013

on jira I have a project created and then an issue. but I saw no logs on the screen.

Onder Yesil February 18, 2013

WHEN I IMPORT THE PLUGIN THEN I GET THE NEXT ERROR.

[INFO] [talledLocalContainer] 2013-02-19 16:09:18,566 pool-5-thread-1 ERROR ad
n 969x805x1 n9xoeh 127.0.0.1 /rest/plugins/1.0/ [atlassian.plugin.loaders.Scan
ngPluginLoader] Unable to deploy plugin 'com.example.tutorial.plugins.new-list
er-plugin', file Unit: D:\downloads\atlassian-tutorial-jira-event-listener-org
arget\jira\home\plugins\installed-plugins\plugin_6484829461368378809_new-liste
r-plugin-1.0.jar (1361286553286)
[INFO] [talledLocalContainer] com.atlassian.plugin.util.validation.ValidationE
eption: The key is required: <Export-Package>
[INFO] [talledLocalContainer] com.example.tutorial.plugins.IssueCrea
dResolvedListener
[INFO] [talledLocalContainer] </Export-Package>
[INFO] [talledLocalContainer] at com.atlassian.plugin.util.validation.Valida
onPattern.evaluate(ValidationPattern.java:70)
[INFO] [talledLocalContainer] at com.atlassian.plugin.descriptors.AbstractMo
leDescriptor.validate(AbstractModuleDescriptor.java:130)
[INFO] [talledLocalContainer] at com.atlassian.plugin.descriptors.AbstractMo
leDescriptor.init(AbstractModuleDescriptor.java:74)
[INFO] [talledLocalContainer] at com.atlassian.plugin.descriptors.Unloadable
duleDescriptorFactory.createUnloadableModuleDescriptor(UnloadableModuleDescrip
rFactory.java:32)
[INFO] [talledLocalContainer] at com.atlassian.plugin.parsers.XmlDescriptorP
ser.createModuleDescriptor(XmlDescriptorParser.java:219)
[INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.factory.OsgiPlugi
mlDescriptorParser.createModuleDescriptor(OsgiPluginXmlDescriptorParser.java:4

[INFO] [

Jobin Kuruvilla [Adaptavist]
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

Try after removing the whole Export Package section. You don't need it.

Onder Yesil February 18, 2013

I removed but i get next error

2013-02-19 16:09:05,244 Spring executor 2 ERROR [internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] Unable to create application context for [com.example.tutorial.plugins.new-listener-plugin], unsatisfied dependencies: none
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/osgi]
Offending resource: URL [bundle://102.0:0/META-INF/spring/atlassian-plugins-component-imports.xml]

at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1294)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
at at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)

Jobin Kuruvilla [Adaptavist]
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

component-import doesn't have description I guess. Try this:

&lt;component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher" /&gt;

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

<font><font>public</font></font><font><font>void</font></font> afterPropertiesSet() <font><font>throws</font></font>

Exception {

// register ourselves with the EventPublisher

<font></font>

eventPublisher.register(

<font></font><font><font>this</font></font>

);<font></font>

System.out.println(

<font></font>

"REGISTERED"

);

}

/**

* Called when the plugin is being disabled or removed.

<font></font>

*

<font></font>

<font><font>@throws</font></font>

Exception

*/

@

Override

<font><font>public</font></font><font><font>void</font></font> destroy() <font><font>throws</font></font>

Exception {

// unregister ourselves with the EventPublisher

<font></font>

eventPublisher.unregister(

<font></font><font><font>this</font></font>

);<font></font>

System.out.println(

<font></font>

"DESTROYED"

);

}

Onder Yesil February 18, 2013

I get know from JIRA PLUGIN SCREEN:

The plugin has been installed but cannot be enabled. Please refer to the logs for more information.
in the LOG i See same error:
2013-02-19 16:51:09,837 Spring executor 16 ERROR onder 981x34x2 xkne3z 127.0.0.1 /rest/plugins/1.0/ [plugin.osgi.factory.OsgiPlugin] Unable to start the Spring context for plugin com.example.tutorial.plugins.new-listener-plugin
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/osgi]
Offending resource: URL [bundle://103.0:0/META-INF/spring/atlassian-plugins-component-imports.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
Sriteja Bongu June 19, 2013

Did you manage to find solution for this? I am trying the same sample plugin with same results.

Any help would be appreciated

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