ScriptRunner : Getting NoClassDefFoundError for GroovyObject

Rohan Sakhale February 20, 2014

Hi,

In continuation with the problem asked previously for adding custom listener as a groovy class https://answers.atlassian.com/questions/259127/how-to-add-custom-listener-groovy-class-for-script-runner-plugin

We were still not able to figure out the proper solution as now we are getting NoClassDefFoundError for [CannedScriptListener]:groovy/lang/GroovyObject

Have also referred to https://answers.atlassian.com/questions/107156/where-to-place-a-custom-listener-for-script-runner-version-2/107221answered by Jamie and we don't see any groovy jar in the lib's

Also we noticed that script runner engine is " Groovy (Groovy Scripting Engine, version: 2.0, registered extensions: [groovy])" and if we run the following code

GroovySystem.getVersion()

the output seen is 1.8.5

Can you please help figure out what we are missing out here and help us run our Custom Listener.

Thanks for your support in advance


6 answers

1 accepted

1 vote
Answer accepted
Henning Tietgens
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 20, 2014

You have to place your script under WEB-INF/classes/com/abc/jira/scriptrunner/scripts/IssuePostUpdateListener.groovy and import that as com.abc.jira.scriptrunner.scripts.IssuePostUpdateListener

Did you?

And there a some other things:

  • import org.apache.log4j.Category is missing
  • Collection<MutableIssue> subTaskList = issue.getSubTaskObjects() could be a problem, because it returns Collection<Issue>
Rohan Sakhale February 20, 2014

I have placed groovy file on the same location, I had ran this script on groovy console and no error's were found

I have updated the MutableIssue to regular Issue and have also added the import line

But still I get same error

Cause

Referer URL: http://ind-rsakhale2:2990/jira/secure/admin/groovy/CannedScriptListener.jspa?cannedScript=com.onresolve.jira.groovy.canned.workflow.listeners.CustomListener&atl_token=BMT7-7PUT-AYWX-I98G|7813ab77a77994975051d08a832995cf52df965d|lin

java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
Henning Tietgens
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 20, 2014

Which version of Script Runner and JIRA do you use? Did you add the listener as Script Listener->Custom Listener or as Listener?

Rohan Sakhale February 20, 2014

On my local machine both Jira (6.1.x) & Script Runner (2.1.16) are running on latest version.

Yes, I added as Script Listener > Custom Listener.

Also, I tried removing the plugin and re-installing again, nothing helped.

Are we supposed to add additional groovy jar that contains this class object?

Henning Tietgens
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 20, 2014

You shouldn't have to install any additional jar. I don't have another idea what could lead to the error message.

Rohan Sakhale March 5, 2014

Thanks Henning for all your valuable comments, the CustomListener is finally @Work:)

Henning Tietgens
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 5, 2014

It would be nice if you share here how you solved your problem. Maybe sometime someone has the same problem...

Rohan Sakhale March 5, 2014

The problem was solved by removing .class file from the /WEB-INF/classes and just keeping .groovy file and secondly if you see my code above, there was a mistake made in class name provided for Logger which was named previously and class name later changed was pending to be changed in Logger which gave NoClassDefError. That was certainly manual mistake which led for so much trouble in understanding it, but finally it sounds so cool after this is being solved.

Thanks for your help Henning :)

0 votes
Rohan Sakhale February 20, 2014

I have added this code in a groovy file and have placed the file as per the location you had said previously WEB-INF/classes

I am trying to add this class as a Custom Listener on event Issue Update for all projects

Below is the partial stack trace

Could not execute action [CannedScriptListener]:groovy/lang/GroovyObject
java.lang.NoClassDefFoundError: groovy/lang/GroovyObject at
java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClassCond(Unknown Source) at
java.lang.ClassLoader.defineClass(Unknown Source) at
java.security.SecureClassLoader.defineClass(Unknown Source) at
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818) at
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) at
java.lang.ClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
0 votes
Rohan Sakhale February 20, 2014

Hi Henning,

Here is the Listener source code used

package com.abc.jira.scriptrunner.scripts

import java.util.Collection
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.UserUtils

class IssuePostUpdateListener extends AbstractIssueEventListener{
	Category log = Category.getInstance(PostUpdationListener.class)
	
	@Override
	void workflowEvent(IssueEvent event){
		IssueManager issueManager = ComponentAccessor.getIssueManager()
		CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

		Issue issue = event.getIssue()

		CustomField qeLeadCF = customFieldManager.getCustomFieldObjectByName("QE Lead")

		ApplicationUser qeLeadVal = (ApplicationUser) issue.getCustomFieldValue(qeLeadCF)

		Collection&lt;Version&gt; versionList = issue.getFixVersions()

		Collection&lt;MutableIssue&gt; subTaskList = issue.getSubTaskObjects()

		for (MutableIssue mi in subTaskList) {
			
			 if (mi.getIssueTypeObject().getName().equals("QA Sub-task")) {
				
				mi.setFixVersions(versionList)
				
				mi.setAssignee(UserUtils.getUser(qeLeadVal.getUsername()))
				Issue updatedIssue = issueManager.updateIssue(issue.getReporter(), mi,EventDispatchOption.ISSUE_UPDATED, false)        
				assert updatedIssue.getCustomFieldValue(qeLeadCF).equals(qeLeadVal)
				assert updatedIssue.getAssigneeUser().equals(qeLeadVal)
			}
		}
	}
}

0 votes
Henning Tietgens
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 20, 2014

Could you please post your listener source (if it's sensible information delete some parts but don't change the structure of the script), where it's installed, how it's configured in Script Runner and the complete exception stack trace?

0 votes
Rohan Sakhale February 20, 2014

Hi Sameera,

Following is seen while trying to add custom listener

Could not execute action [CannedScriptListener]:groovy/lang/GroovyObject

java.lang.NoClassDefFoundError: groovy/lang/GroovyObject at java.lang.ClassLoader.defineClass1(Native Method)

0 votes
Sameera Shaakunthala [inactive]
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 20, 2014

Can you please post the entire line of log which contains 'NoClassDefFoundError'. I think it should contain the class name it has been looking for.

Suggest an answer

Log in or Sign up to answer