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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,462,113
Community Members
 
Community Events
176
Community Groups

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

Atlassian Community Events