Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Script runner fails to run in post function

I am to run a post function through a script written in groovy with Script runner but it fails although it run fine through my console.

it seems some dependency is missing but i am not sure which one .

this is the error message :

Error: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/ivy/plugins/resolver/DependencyResolver at com.adaptavist.sr.cloud.workflow.AbstractScript.parseScript(AbstractScript.groovy:48) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:31) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at com.adaptavist.sr.cloud.workflow.RunScript.run(RunScript.groovy:18) Caused by: java.lang.ClassNotFoundException: org.apache.ivy.plugins.resolver.DependencyResolver. Current classpath: file:/var/task/:file:/var/task/lib/FastInfoset-1.2.18.jar:file:/var/task/lib/aws-lambda-java-core-1.2.1.jar:file:/var/task/lib/aws-lambda-java-log4j-1.0.1.jar:file:/var/task/lib/builder-2.8.8.jar:file:/var/task/lib/checker-qual-3.5.0.jar:file:/var/task/lib/commons-codec-1.10.jar:file:/var/task/lib/fast-classpath-scanner-3.1.13.jar:file:/var/task/lib/gmbal-4.0.1.jar:file:/var/task/lib/groovy-2.5.12.jar:file:/var/task/lib/groovy-beans-with-jackson-immutables-module-1.0.jar:file:/var/task/lib/groovy-datetime-2.5.12.jar:file:/var/task/lib/groovy-dateutil-2.5.12.jar:file:/var/task/lib/groovy-json-2.5.12.jar:file:/var/task/lib/groovy-jsr223-2.5.12.jar:file:/var/task/lib/groovy-nio-2.5.12.jar:file:/var/task/lib/groovy-sql-2.5.12.jar:file:/var/task/lib/groovy-templates-2.5.12.jar:file:/var/task/lib/groovy-xml-2.5.12.jar:file:/var/task/lib/ha-api-3.1.12.jar:file:/var/task/lib/httpasyncclient-4.1.4.jar:file:/var/task/lib/httpclient-4.5.6.jar:file:/var/task/lib/httpcore-4.4.10.jar:file:/var/task/lib/httpcore-nio-4.4.10.jar:file:/var/task/lib/httpmime-4.5.6.jar:file:/var/task/lib/jackson-annotations-2.11.3.jar:file:/var/task/lib/jackson-core-2.11.3.jar:file:/var/task/lib/jackson-databind-2.11.3.jar:file:/var/task/lib/jakarta.activation-1.2.2.jar:file:/var/task/lib/jakarta.activation-api-1.2.2.jar:file:/var/task/lib/jakarta.annotation-api-1.3.5.jar:file:/var/task/lib/jakarta.jws-api-2.1.0.jar:file:/var/task/lib/jakarta.xml.bind-api-2.3.3.jar:file:/var/task/lib/jakarta.xml.soap-api-1.4.2.jar:file:/var/task/lib/jakarta.xml.ws-api-2.3.3.jar:file:/var/task/lib/jaxb-impl-2.3.3.jar:file:/var/task/lib/jaxws-rt-2.3.3.jar:file:/var/task/lib/jcl-over-slf4j-1.7.30.jar:file:/var/task/lib/json-20180130.jar:file:/var/task/lib/jsr305-3.0.2.jar:file:/var/task/lib/log4j-1.2.17.jar:file:/var/task/lib/management-api-3.2.2.jar:file:/var/task/lib/metrics-core-4.1.14.jar:file:/var/task/lib/metrics-json-4.1.14.jar:file:/var/task/lib/mimepull-1.9.13.jar:file:/var/task/lib/mssql-jdbc-9.2.1.jre11.jar:file:/var/task/lib/mysql-connector-java-8.0.23.jar:file:/var/task/lib/pfl-basic-4.1.0.jar:file:/var/task/lib/pfl-tf-4.1.0.jar:file:/var/task/lib/policy-2.7.10.jar:file:/var/task/lib/postgresql-42.2.19.jar:file:/var/task/lib/protobuf-java-3.11.4.jar:file:/var/task/lib/saaj-impl-1.5.2.jar:file:/var/task/lib/shared.jar:file:/var/task/lib/slf4j-api-1.7.30.jar:file:/var/task/lib/slf4j-log4j12-1.7.30.jar:file:/var/task/lib/stax-ex-1.8.3.jar:file:/var/task/lib/stax2-api-4.1.jar:file:/var/task/lib/streambuffer-1.5.9.jar:file:/var/task/lib/sysout-over-slf4j-1.0.2.jar:file:/var/task/lib/unirest-java-adaptavist-2.6.28.jar:file:/var/task/lib/woodstox-core-5.1.0.jar at lambdainternal.CustomerClassLoader.findClass(CustomerClassLoader.java:63) at com.adaptavist.sr.cloud.workflow.AbstractScript.parseScript(AbstractScript.groovy:48) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:31) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at com.adaptavist.sr.cloud.workflow.RunScript.run(RunScript.groovy:18) at com.adaptavist.sr.cloud.MainHandler.executeScript(MainHandler.groovy:376) at com.adaptavist.sr.cloud.MainHandler.processInput(MainHandler.groovy:334) at com.adaptavist.sr.cloud.MainHandler.access$0(MainHandler.groovy) at com.adaptavist.sr.cloud.MainHandler$_handleRequest_closure1.doCall(MainHandler.groovy:154) at com.adaptavist.sr.cloud.MainHandler$_handleRequest_closure1.call(MainHandler.groovy)

1 answer

0 votes

Hi,

It will be helpful if you can provid your code to see if we can see some error 

this is the code ( i ommited the url and other credentials) . basically i am trying first to fetch an Oauth2 token and post something to an endpoint.

 

@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.1')
import groovyx.net.http.RESTClientimport groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.URLENC
import static groovyx.net.http.ContentType.JSON
import static groovyx.net.http.Method.POST
import static groovyx.net.http.Method.PUT

def client = new RESTClient ( 'https://....' )
def site = new HTTPBuilder'https://....' )

site.auth.basic 'dmac''foo'
def accessToken

site.post(path: '/oauth2/token',           
body: [username:
'xxx',password:'xxxxx',grant_type:'password'], 
requestContentType: URLENC ) { 
respreader ->
System.out << "Token response: " << reader
 println()              
accessToken = reader[
'access_token']}


println("Access Token: ${accessToken}")

def api = new RESTClient ( 'https://....' )

def resp = api.put(path: "/api/V1/secret-access-requests",
body: [expirationDate:'2021-07-14 17:30:00',startDate:'2021-07-06T14:33:00.000',responseComment:'approved',secretAccessRequestId:'1222',status:"Approved"],
headers: ['Authorization'"Bearer ${accessToken}"],
requestContentType: groovyx.net.http.ContentType.JSON)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

Atlympic Event: Jira Service Managemnt

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

99 views 0 1
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