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

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

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


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

Good point, will do. Thanks.

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.

Ran into this problem with my scripts folder too.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,376 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you