The simplest Groovy

Running this:

import com.opensymphony.workflow.InvalidInputException

invalidInputException = newInvalidInputException("Incident Resolved is not filled.")

puts this error in the JIRA screen just as expected, but also produces this in catalina.out - why?

at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
	at Script18.run(Script18.groovy:6)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:103)
	at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:102)
	at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:62)
	at com.onresolve.jira.groovy.GroovyValidator.validate(GroovyValidator.java:44)

Even though it works, error message is concerning...

1 answer

you have to use as follows

InvalidInputException e= new InvalidInputException();
 e.addError("error message");
 throw e;

refer this question

https://answers.atlassian.com/questions/225982/simple-script-validation?page=1#226000

Thank, the script

import com.opensymphony.workflow.InvalidInputException


InvalidInputException e= new InvalidInputException();
 e.addError("Incident Resolved is not filled.");
 throw e;

Gives:

2013-11-06 12:06:07,600 http-bio-6060-exec-3 ERROR npn 726x339302x1 3wpz9n 77.243.49.10 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: [InvalidInputException: [Error map: [{}]] [Error list: [[Incident Resolved is not filled.]]]
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
	at Script20.run(Script20.groovy:6)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:103)
	at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:102)
	at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:62)
	at com.onresolve.jira.groovy.GroovyValidator.validate(GroovyValidator.java:44)

This may be because of the thrown execption - and behavior as designed? Still - my catalina.out is filled with exeptions enough already...

NB - you don't have to do it like the code Rambanam posted - both ways are valid, and both will produce the same result.

Hi Jamie and Rambanam,

The question actually primarily was a question of: Can I avoid the stacktraces in catalina.out from (working) code?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

78 views 0 3
Join discussion

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