Our custom listener plugin is not listening after the jira service restart?

Hi Team,

We have developed a custom listener plugin to update custom field value based another custom field value,and it is working fine when server is up and running. And the problem is, it is stop working when we restart the jira service/sever.

Seems to be jira is not picking the our custom listener plugin features while restarting the jira service.

To make it work, again we need to upload the plugin after server up and running.
We are loading plugin through Application under Add-on section?

Hello surigongati! Just wanted to clarify for you that this is a community of developers and not official support; but you get a lot of help!

Did you list your listener under the Spring plugin-context xml file, (Under META-INF package) in resources?
You should have something like this:
<bean id="myCustomListenerId" class="com.myjiraplugin.plugin.jira.listener.CustomListener"/>
Listened in

Hi Kallas,
Thank you for the reply.I have added bean to plugin-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.atlassian.com/schema/atlassian-scanner
        http://www.atlassian.com/schema/atlassian-scanner/atlassian-scanner.xsd">
    <atlassian-scanner:scan-indexes/>
    <bean id="moduleListenerId" class="com.gtnexus.module.plugin.ModuleChangeListener"/>
</beans>

But still it is not working after the server restart.I am missing any information?

Does the component ID matches your key in atlassian-plugin xml?

    <component key="myCustomListener"
               class="com.private.plugin.jira.listener.myCustomListener"
               public="false">
        <description>Sends special email once issue updated
        </description>
    </component>

Hi

we are using atlassian-spring-scanner-runtime
I don’t think so,need of importing component in atlassina-jira.xml file.

<atlassian-plugin key="${atlassian.plugin.key}" 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}" />
        <param name="plugin-icon">images/pluginIcon.png</param>
        <param name="plugin-logo">images/pluginLogo.png</param>
    </plugin-info>

    <!-- add our i18n resource -->
    <resource type="i18n" name="i18n" location="gtn-module-plugin"/>
    
    <!-- add our web resources -->
    <web-resource key="gtn-module-plugin-resources" name="gtn-module-plugin Web Resources">
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        
        <resource type="download" name="gtn-module-plugin.css" location="/css/gtn-module-plugin.css"/>
        <resource type="download" name="gtn-module-plugin.js" location="/js/gtn-module-plugin.js"/>
        <resource type="download" name="images/" location="/images"/>

        <context>gtn-module-plugin</context>
    </web-resource>
    <component key="moduleListenerId" class="com.gtnexus.module.plugin.ModuleChangeListener" public="false">
        <description>Sends special email once issue updated</description>
    </component>
</atlassian-plugin> ```

I missing any thing in java listener class. I am missing any spring annotations?

@Named("ModuleChangeListener")
public class ModuleChangeListener implements InitializingBean, DisposableBean {
private static final Logger log = Logger.getLogger(ModuleChangeListener.class);

@ComponentImport
private final EventPublisher eventPublisher;
@ComponentImport
private final EventTypeManager eventTypeManager;
@ComponentImport
private final AttachmentManager attachmentManager;
@ComponentImport
private final ApplicationProperties applicationProperties;

@Inject
public ModuleChangeListener(EventPublisher eventPublisher, EventTypeManager eventTypeManager,
		AttachmentManager attachmentManager, ApplicationProperties applicationProperties) {
	this.eventPublisher = eventPublisher;
	this.eventTypeManager = eventTypeManager;
	this.attachmentManager = attachmentManager;
	this.applicationProperties = applicationProperties;
}

@Override
public void afterPropertiesSet() throws Exception {
	this.eventPublisher.register(this);
}

@Override
public void destroy() throws Exception {
	this.eventPublisher.unregister(this);
}

@EventListener
public void onEvent(IssueEvent event) {
	//my code start here and it is not working when server is restarted.

}
}

Answer:“Due to the shortcomings of the component initialisation stage, a listener on the PluginEnabledEvent is the earliest time that you should attempt to do any serious wiring into JIRA. For example, if your plugin needs to ensure there are particular custom fields created in JIRA for the plugin to function properly, the plugin should attempt to create them during this stage, and not earlier.”