ScriptRunner : Getting NoClassDefFoundError for GroovyObject

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
Henning Tietgens Community Champion Feb 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>

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 Community Champion Feb 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?

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 Community Champion Feb 20, 2014

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

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

Henning Tietgens Community Champion Mar 05, 2014

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

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

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.

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 vote
Henning Tietgens Community Champion Feb 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?

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

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

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

1,013 views 3 12
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