jfrog / artifactory-scripts

Scripts for Artifactory (Usually, for REST API), community driven.
Apache License 2.0
148 stars 166 forks source link

[ERROR] java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport #20

Closed gabor523 closed 5 years ago

gabor523 commented 8 years ago

Hi,

I wanted to try this groovy script on my Jenkins but I got this error. Error: java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2531) at java.lang.Class.getDeclaredMethods(Class.java:1855) at org.codehaus.groovy.reflection.CachedClass$3$1.run(CachedClass.java:84) at java.security.AccessController.doPrivileged(Native Method) at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:81) at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:79) at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)

Do you have any idea what the problem is here? Or missing something in Jenkins?

Thanks and Regards, Gabor

markgalpin commented 8 years ago

Which script are you having an issue with?

gabor523 commented 8 years ago

This is the script: https://github.com/JFrogDev/artifactory-scripts/blob/master/cleanup/aqlCleanup.groovy

markgalpin commented 8 years ago

If you change: groovy.json.internal.LazyMap to 'Map' on line 49, does that fix it?

gabor523 commented 8 years ago

Unfortunately it doesn't solve this problem. :(

markgalpin commented 8 years ago

So given that the top-level issue mentions ivy, there may be an issue with the grape resolver. You can try these things: 1.) What version of groovy are you using? (Check this with groovy --version. I am currently testing against 2.4.7) 2.) What does your ~/.groovy/grapeConfig.xml say? 3.) have you tried clearing the ~/.groovy/grapes and ~/.m2/repository caches and pulling it again?

gabor523 commented 8 years ago

I didn't find ~/.groovy/grapeConfig.xml I have only ~/.groovy/grapes and ~/.m2/settings.xml Is it possible problem? But I found other things in Jenkins' configuration:

markgalpin commented 8 years ago

If you don't have a grapeConfig it just means you're using the default which is fine. And no m2 repo is also fine (its just a cache)

Reading this more, this error seems to be a result of the system not being able to find the ivy library grape uses for the grab statement to work. This should be in the lib directory of your groovy installation. Is it present?

You might want to try executing the script manually on the box to confirm it isn't something else about the jenkins context.

gabor523 commented 8 years ago

I don't know where I can find this lib directory of your groovy installation. Can you say any suggestions about this? If I check syntax for this script on the box in the Jenkins config then it will show same error as in execution. javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport

markgalpin commented 8 years ago

We don't install groovy. Groovy should be pre-installed on the jenkins build machine. There should be a GROOVY_HOME variable there should also be something in your path about groovy.

gabor523 commented 8 years ago

What is the situation if GROOVY_HOME variable doesn't exist in section of "Environment Variables" in Jenkins' job? But other groovy script execute on this Jenkins without problem.

bence-takacs commented 7 years ago

This is a common Jenkins issue: basically it supports @Grape but does not put it's ivy dependency on the classpath. Meaning: you will get 'java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport' if you want to use @Grape/@Grape. The only exception is the ’Job DSL’ plugin :-)

Solutions:

( see: https://groups.google.com/forum/#!topic/jenkinsci-issues/wMdNET2L3TU see also: https://issues.jenkins-ci.org/browse/JENKINS-16361 and https://issues.jenkins-ci.org/browse/JENKINS-18349 and https://issues.jenkins-ci.org/browse/JENKINS-18400)

DarthFennec commented 5 years ago

aqlCleanup.groovy is deprecated. Closing this as no longer relevant.