I have created a groovy class (in the script root dir) which uses a library included in an installed plugin
<root>/Testclass.groovy
import org.apache.log4j.*; // Logger import com.atlassian.jira.component.ComponentAccessor; import com.mks.api.*; import com.mks.api.response.*; import agileconnector.*; public class Testclass { ... // Logger final static Logger log = Logger.getLogger("Testclass"); final Long issueId; final String userName; String impersonatedUserName, impersonatedUserPw; boolean onProductiveServer = null ; // set by method setProdOrTestServer() // Integrity Classes final IntegrationPointFactory ipf; final IntegrationPoint ip; final Session session; final CmdRunner runner; public Testclass(String name, Long id){ // ============================== init ============================== log.setLevel(Level.DEBUG); this.userName = name; this.issueId = id; setProdOrTestServer(); setImpersonatedUser(); try { // ==================== create Connection to IMS ==================== ipf = IntegrationPointFactory.getInstance(); if (onProductiveServer){ ip = ipf.createIntegrationPoint(imsProdServerHostname, imsProdServerPort_si, imsApiMajorVersion, imsApiMinorVersion); } else { ip = ipf.createIntegrationPoint(imsTestServerHostname, imsTestServerPort_si, imsApiMajorVersion, imsApiMinorVersion); } session = ip.createSession(impersonatedUserName, impersonatedUserPw); session.setTimeout(imsSessionTimeout); // set Timeout 1.200.000 Millisekunden -> 20 Minuten runner = session.createCmdRunner(); // ======================== execute commands ======================== command(); ... } } // methods... }
<root>/test.groovy
import Testclass; new Testclass("user", 1L );
When I call the script test.groovy at the script consolethe command is successfully executed.
But when I try creating the class in a REST Endpoint Script (called when pressing a Web Item Button) or Script Listener
REST Endpoint Script
<root>/do.groovy
... import Testclass; do(httpMethod: "GET") { MultivaluedMap queryParams -> ... new Testclass(userName, issueId); ... }
I always get the error message:
2016-12-06 14:31:24,991 http-nio-8080-exec-10 ERROR user 871x153353x1 52et7rn /rest/scriptrunner/latest/custom/doSomething [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: startup failed: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: file:/C:/Program%20Files/Atlassian/Application%20Data/JIRA/scripts/Testclass.groovy: 31: unable to resolve class IntegrationPointFactory @ line 31, column 3. final IntegrationPointFactory ipf; ^ file:/C:/Program%20Files/Atlassian/Application%20Data/JIRA/scripts/Testclass.groovy: 32: unable to resolve class IntegrationPoint @ line 32, column 3. final IntegrationPoint ip; ^ file:/C:/Program%20Files/Atlassian/Application%20Data/JIRA/scripts/Testclass.groovy: 33: unable to resolve class Session @ line 33, column 3. final Session session; ^ file:/C:/Program%20Files/Atlassian/Application%20Data/JIRA/scripts/Testclass.groovy: 34: unable to resolve class CmdRunner @ line 34, column 3. final CmdRunner runner; ^
What is the difference between createing the class in a script outgoing from the script console, instead of a REST Endpoint Script or Script Listener??
JIRA v.7.1.9
ScriptRunner v4.3.13
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.