script runs via the console and not via the workflow validator nor via the post functions

Bruno BLAISE October 28, 2012

I'm using groovyrunner for a while and I'm addict :-)

We did a jira migration from the version 4.2.4 to the version 5.1.6. Today I did a groovyrunner upgrade to the version 2.0.9.

I have rework the scripts to be aligned with the version 5.

The scripts are working via the script console and not via the workflows :-(

I receive the following errors:

2012-10-29 09:57:08,061 http-13032-1 ERROR xxx 597x96203x2 80h7pw xxxxx /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script23.groovy: 3: unable to resolve class com.atlassian.jira.issue.Issue
 @ line 3, column 1.
   import com.atlassian.jira.issue.Issue
   ^
Script23.groovy: 4: unable to resolve class com.atlassian.mail.Email
 @ line 4, column 1.
   import com.atlassian.mail.Email
   ^
Script23.groovy: 1: unable to resolve class com.atlassian.jira.ComponentManager
 @ line 1, column 1.
   import com.atlassian.jira.ComponentManager
   ^
Script23.groovy: 5: unable to resolve class com.atlassian.mail.MailFactory
 @ line 5, column 1.
   import com.atlassian.mail.MailFactory
   ^
Script23.groovy: 2: unable to resolve class com.atlassian.jira.issue.CustomFieldManager
 @ line 2, column 1.
   import com.atlassian.jira.issue.CustomFieldManager
   ^
Script23.groovy: 7: unable to resolve class com.opensymphony.util.TextUtils
 @ line 7, column 1.
   import com.opensymphony.util.TextUtils
   ^
Script23.groovy: 6: unable to resolve class com.atlassian.mail.server.SMTPMailServer
 @ line 6, column 1.
   import com.atlassian.mail.server.SMTPMailServer
   ^
7 errors
        at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
        at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:103)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:195)
        at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:97)
        at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:57)
        at com.onresolve.jira.groovy.GroovyFunctionPlugin.execute(GroovyFunctionPlugin.java:35)
        at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:1050)
        at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1446)
        at com.opensymphony.workflow.AbstractWorkflow.doAction(AbstractWorkflow.java:564)
        at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowActionInsideTxn(OSWorkflowManager.java:894)
        at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowAction(OSWorkflowManager.java:850)
        at com.atlassian.jira.bc.issue.DefaultIssueService.transition(DefaultIssueService.java:449)
        at com.atlassian.jira.web.action.issue.CommentAssignIssue.doExecute(CommentAssignIssue.java:196)  <+1> (ActionSupport.java:165)
        at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:82)  <+7> (DefaultInterceptorChain.java:39) (NestedInterceptorChain.java:31) (ChainedInterceptor.java:16) (DefaultInterceptorChain.java:35) (GenericDispatcher.java:221) (GenericDispatcher.java:150) (JiraWebworkActionDispatcher.java:153)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)  <+14> (ApplicationFilterChain.java:290) (ApplicationFilterChain.java:206) (ChainedFilterStepRunner.java:78) (ApplicationFilterChain.java:235) (ApplicationFilterChain.java:206) (XContentTypeOptionsNoSniffFilter.java:22) (AbstractHttpFilter.java:31) (ApplicationFilterChain.java:235) (ApplicationFilterChain.java:206) (HeaderSanitisingFilter.java:44) (ApplicationFilterChain.java:235) (ApplicationFilterChain.java:206) (IteratingFilterChain.java:46) (DelegatingPluginFilter.java:66)

As you can see the stack trace, it does not find the jira classes. It seems linked with the class loader.

Any ideas and helps are welcome.

Bruno

6 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Bruno BLAISE November 8, 2012

Jamie,

Good news :-)

My colleague found the problem. With Jira 4 + GroovyRunner 1.7, we were deploying the groovy libraries within the tomcat lib folder... and during the migration to jira 5 + groovyrunner 2, the groovy libraries were still there, and it was conflicting with the groovy libs bundled within groovyrunner 2.0.x

Thus it is resolved,

Sorry for this non bug and again thanks for your help and for groovyrunner

Bruno

0 votes
Shaikh Moiz June 3, 2014

Hello Jamie,

I am also getting the same error, My script code is working fine in script runner console, but when i add that script in behaviours plugin for custom field XYZ, I got the same error as,

Compilation failure: startup failed: Script1.groovy: 14: unable to resolve class com.atlassian.mail.Email @ line 14, column 1. import com.atlassian.mail.Email; ^ 1 error

0 votes
Bruno BLAISE October 28, 2012

Hi Jamie,

It's strange to see that the exception are throwned on the atlassian classes.

The following code works:

import org.apache.log4j.Category

Category log = Category.getInstance("com.atlassian.jira.service.services.DebugService")

log.debug "hello from the validator"

And not

import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager

Category log = Category.getInstance("com.atlassian.jira.service.services.DebugService")

log.debug "hello from the validator"

The difference is the import of the ComponentManager :-(

Bruno BLAISE October 28, 2012

I will do a test with a fresh installation, and step by step will add plugins after plugins.

I come back asap with another result. I hope ;-)

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 28, 2012

It's the same code whether running from admin console or running from a function... so I'm at a loss. Can you run up a test instance of 5.1.6 and try it? Possibly some other plugin interfering... if you like email me privately the whole system log from a cold start. firstname.lastname@gmail.com.

Bruno BLAISE October 28, 2012

and the following exception is throwned within the log file (exception.txt)

and the following screen appears

the

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 29, 2012

You didn't add any additional jars to web-inf/lib? Same container in both cases?

What happens if you revert prod to scriptrunner 2.0.6 or .7?

What system properties do you have in prod, are they similar to your dev instance?

> Good news or bad news, I don't know?

Good in that there's no showstopping bug in the plugin, bad for you in that you're no closer to finding the problem :-(

Bruno BLAISE October 29, 2012

I agree with you to say that it is a good news for the plugin and I'm more and more convinced that the problem is located within our installation, but where?

The problem appeared with groovyrunner 2.0.7 when we did the jira migration from 4.2.4 to 5.1.6

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 29, 2012

Bruno, I meant replace firstname lastname in firstname.lastname@gmail.com with my actual first and last name, I don't want to put my email address here because of spammers. Or you can give me your address.

0 votes
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 28, 2012

I can't reproduce this thank god. 2.0.8 and 9 is solely concerned with security issues, ie anti-XSRF and websudo.

2.0.7 changes may be getting you? I can't think what though. Did you have a customised build at all?

Can you create a new very basic script on eg Start Progress, with just one import and one debug line?

Nothing to do with line endings etc?

Bruno BLAISE October 29, 2012

I did the following operations:

  • installed a fresh jira 5.1.6 standalone
  • installed groovyrunner 2.0.9
  • created a workflow with a post-function to call the script within the previous comment
  • associated the workflow with a test project
  • created a testing issue
  • started without any other plugins and no exception during the workflow execution :-)
  • started to install all the plugins used in production and each time, reexecuted the workflow transition

And after all the installation, I have no exception at all.

Good news or bad news, I don't know?

Now it seems linked with the execution environment.


0 votes
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 28, 2012

Looks pretty bad... let me try to reproduce.

0 votes
Vishwajeet Singh
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 28, 2012

To me it looks it's not able to understand if it's a grrovy script.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events