It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ClassNotFoundException for ShareService Edited

Yanduganov Andrey Jan 12, 2018

Here is the code:

import com.atlassian.jira.plugins.share.ShareService
import com.atlassian.jira.plugins.share.ShareBean

@WithPlugin
("com.atlassian.jira.jira-share-plugin")
@PluginModule
ShareService shareService
...
...
...
shareService.shareIssue(result)

I have tried to run it in Script Rnner console and in custom script post function.

In the console it works fune but in post function i have an error:

2018-01-12 15:44:06,670 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2018-01-12 15:44:06,671 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: SHOPSTASK-71101, actionId: 181, file: <inline script>
java.lang.reflect.InvocationTargetException
	at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runScriptAndGetContext(ScriptRunnerImpl.groovy:156)
	at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$3.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$3.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runStringAsScript(ScriptRunnerImpl.groovy:144)
	at com.onresolve.scriptrunner.runner.ScriptRunner$runStringAsScript$2.call(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate.doScript(CustomScriptDelegate.groovy:66)
	at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate$doScript.call(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction.doScript(CustomScriptFunction.groovy:44)
Caused by: java.lang.NoClassDefFoundError: com/atlassian/jira/plugins/share/ShareService
	at Script572.<init>(Script572.groovy)
Caused by: java.lang.ClassNotFoundException: com.atlassian.jira.plugins.share.ShareService
	... 1 more

How to solve this problem? 

P.S.

Sometimes I have another error:

java.lang.NoClassDefFoundError: com/atlassian/jira/plugins/share/ShareBean
at Script723$_run_closure2.doCall(Script723.groovy:94)
at Script723.run(Script723.groovy:75)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runScriptAndGetContext(ScriptRunnerImpl.groovy:156)
at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$3.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runStringAsScript(ScriptRunnerImpl.groovy:144)
at com.onresolve.scriptrunner.runner.ScriptRunner$runStringAsScript$2.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate.doScript(CustomScriptDelegate.groovy:66)
at com.onresolve.scriptrunner.canned.jira.utils.CustomScriptDelegate$doScript$2.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction.doScript(CustomScriptFunction.groovy:44)

 P.P.S.

Furthermore I have the same problem when I try to use classes from my own plugin. But this problem is not permanent. E.g. when my code was correct I changed a little thing that doesn't depend on my plugin. After that I've got this error. But when I run my code from the file (not from inline code) I have no problems.

I use JIRA 7.2.3 and Script Runner 5.0.4

1 answer

0 votes

We have a similar issue when trying to load service desk classes.

@WithPlugin("com.atlassian.servicedesk")

it works fine from the script runner's console, but fails randomly when used as workflow postfunction.

We've tried to replcae the @PluginModule with ComponentAccessor.getOSGiComponentInstanceOfType(RequestTypeService), but still get random ClassNotFound errors

java.lang.NoClassDefFoundError: com/atlassian/servicedesk/api/requesttype/RequestTypeService

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar alert! An IT Admin's Guide to Securing Collaboration at Scale

Hello, Atlassian Community! My name is Dave Meyer and I'm a Principal Product Manager at Atlassian. I wanted to give this community a heads up about an upcoming Webinar that might be of interest...

163 views 2 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you