Custom script listener not working after migration JIRA 6.2 => 6.4

Gaël NEUEZ October 6, 2015

Hello,

I was using the custom listener function in JIRA 6.2 without problem.

Now I am evaluating the migration to JIRA6.4, and my listener won't work => nothing happens nor is logged in the catalina.out.

I'm using the scriptrunner version 3.1.4

My script is a groovy class that extends the AbstractIssueEventListener (like in most examples), and the file is on server in $JIRA_INSTALL/atlassian-jira/WEB_INF/classes/com/mycompany/jira/IssueEditedListener.groovy

package com.mycompany.jira.listeners
import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.AbstractEvent
import com.atlassian.jira.event.issue.IssueEvent


class IssueEditedListener extends AbstractIssueEventListener {
   Category log = Category.getInstance(IssueEditedListener.class)
   @Override
   void workflowEvent(IssueEvent event) {
      log.error "Event: ${event.getEventTypeId()} fired for ${event.issue} and caught by IssueEditedListener"
      [...some other code here...]
   }
}

 

Now when I open my custom listener configuration in JIRA, if I enter the name of the class "com.mycompany.jira.listeners.IssueEditedListener" in the "Name of the goovy class" field, I end up with error:Problem loading class/script: groovy.util.ResourceException: Cannot open URL: bundle://165.0:0/null

(same error whatever I put in the field, in fact...)

 

What is wrong with the configuration? Again, it was working just fine with JIRA6.2.7 and scriptrunner 2.1.17.

 

Regards

Gael

 

2 answers

1 accepted

2 votes
Answer accepted
JamieA
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 6, 2015

You need to put it under a script root - and refer to it either as com.mycompany.jira.listeners.IssueEditedListener  or com/mycompany/jira/listeners/IssueEditedListener.groovy

Further examples here: https://scriptrunner.adaptavist.com/latest/jira/listeners.html#_custom_listener_example


Gaël NEUEZ October 6, 2015

Thanks Jamie, this solved the issue. I saw the "Heritage" Custom Listeners section in https://scriptrunner.adaptavist.com/latest/jira/listeners.html#_custom_listener_example, but the point 2) talks about the script roots directory without pointing to the https://scriptrunner.adaptavist.com/latest/jira/#_script_roots Just adding the hyperlink would help a lot of people I think ;) Regards Gael

JamieA
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 6, 2015

Good point, will do. Thanks.

1 vote
AndrewB October 6, 2015

I ran into a similar situation after upgrading ScriptRunner.

 

I used to be able to use the package name followed by the class name like you're attempting. Example: com.custom.MyListener

 

Now I have to put in the path followed by the file name. Example: ...../jira/scripts/com/custom/myListener.groovy

 

Try that, hope it helps. I'm interested to know if you get the package name approach to work.

MikeyS
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.
March 16, 2016

Ran into this problem with my scripts folder too.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events