ow2-proactive / scheduling

Multi-platform Scheduling and Workflows Engine
http://www.activeeon.com/workflows-scheduling
GNU Affero General Public License v3.0
62 stars 55 forks source link

Allow using the @Grab annotation in groovy scripts #2496

Open fviale opened 8 years ago

fviale commented 8 years ago

Currently it is not possible to use the @Grab annotation in groovy scripts executed in a task.

@Grab is a very handy tool allowing to download dynamically from maven dependencies used inside a script.

http://docs.groovy-lang.org/latest/html/documentation/grape.html

The reason seems to be that the classpath does not contain Apache Ivy and probably other dependencies.

Here is the error displayed when using Grab:

[92t0@trydev.activeeon.com;11:16:11] Failed to execute task: org/apache/ivy/core/report/ResolveReport 
[92t0@trydev.activeeon.com;11:16:11] java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.getDeclaredMethods0(Native Method) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.privateGetPublicMethods(Class.java:2902) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.getMethods(Class.java:1615) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1336) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getBeanInfo(Introspector.java:426) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getBeanInfo(Introspector.java:173) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3292) 
[92t0@trydev.activeeon.com;11:16:11] at java.security.AccessController.doPrivileged(Native Method) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3290) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3266) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:254) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.GrapeIvy.$getStaticMetaClass(GrapeIvy.groovy) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.GrapeIvy.<init>(GrapeIvy.groovy:81) 
[92t0@trydev.activeeon.com;11:16:11] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
[92t0@trydev.activeeon.com;11:16:11] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
[92t0@trydev.activeeon.com;11:16:11] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.reflect.Constructor.newInstance(Constructor.java:422) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.newInstance(Class.java:442) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.Grape.getInstance(Grape.java:121) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.Grape.grab(Grape.java:159) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:378) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:321) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:212) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:374) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:151) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:130) 
[92t0@trydev.activeeon.com;11:16:11] at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scripting.Script.execute(Script.java:319) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scripting.ScriptHandler.handle(ScriptHandler.java:76) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor.execute(InProcessTaskExecutor.java:198) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor.execute(InProcessTaskExecutor.java:141) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.forked.env.ExecuteForkedTaskInsideNewJvm.fromForkedJVM(ExecuteForkedTaskInsideNewJvm.java:88) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.forked.env.ExecuteForkedTaskInsideNewJvm.main(ExecuteForkedTaskInsideNewJvm.java:78) 
[92t0@trydev.activeeon.com;11:16:11] Caused by: java.lang.ClassNotFoundException: org.apache.ivy.core.report.ResolveReport 
[92t0@trydev.activeeon.com;11:16:11] at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
[92t0@trydev.activeeon.com;11:16:11] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
[92t0@trydev.activeeon.com;11:16:11] ... 43 more 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor.execute(InProcessTaskExecutor.java:202) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor.execute(InProcessTaskExecutor.java:141) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.forked.env.ExecuteForkedTaskInsideNewJvm.fromForkedJVM(ExecuteForkedTaskInsideNewJvm.java:88) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.forked.env.ExecuteForkedTaskInsideNewJvm.main(ExecuteForkedTaskInsideNewJvm.java:78) 
[92t0@trydev.activeeon.com;11:16:11] Caused by: java.lang.Exception: org/apache/ivy/core/report/ResolveReport 
[92t0@trydev.activeeon.com;11:16:11] java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.getDeclaredMethods0(Native Method) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.privateGetPublicMethods(Class.java:2902) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.getMethods(Class.java:1615) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1336) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getBeanInfo(Introspector.java:426) 
[92t0@trydev.activeeon.com;11:16:11] at java.beans.Introspector.getBeanInfo(Introspector.java:173) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3292) 
[92t0@trydev.activeeon.com;11:16:11] at java.security.AccessController.doPrivileged(Native Method) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3290) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3266) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:254) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.GrapeIvy.$getStaticMetaClass(GrapeIvy.groovy) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.GrapeIvy.<init>(GrapeIvy.groovy:81) 
[92t0@trydev.activeeon.com;11:16:11] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
[92t0@trydev.activeeon.com;11:16:11] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
[92t0@trydev.activeeon.com;11:16:11] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.reflect.Constructor.newInstance(Constructor.java:422) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.Class.newInstance(Class.java:442) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.Grape.getInstance(Grape.java:121) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.Grape.grab(Grape.java:159) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:378) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:321) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254) 
[92t0@trydev.activeeon.com;11:16:11] at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:212) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:374) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:151) 
[92t0@trydev.activeeon.com;11:16:11] at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:130) 
[92t0@trydev.activeeon.com;11:16:11] at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scripting.Script.execute(Script.java:319) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scripting.ScriptHandler.handle(ScriptHandler.java:76) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor.execute(InProcessTaskExecutor.java:198) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor.execute(InProcessTaskExecutor.java:141) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.forked.env.ExecuteForkedTaskInsideNewJvm.fromForkedJVM(ExecuteForkedTaskInsideNewJvm.java:88) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.forked.env.ExecuteForkedTaskInsideNewJvm.main(ExecuteForkedTaskInsideNewJvm.java:78) 
[92t0@trydev.activeeon.com;11:16:11] Caused by: java.lang.ClassNotFoundException: org.apache.ivy.core.report.ResolveReport 
[92t0@trydev.activeeon.com;11:16:11] at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
[92t0@trydev.activeeon.com;11:16:11] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
[92t0@trydev.activeeon.com;11:16:11] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
[92t0@trydev.activeeon.com;11:16:11] ... 43 more 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scripting.Script.execute(Script.java:339) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scripting.ScriptHandler.handle(ScriptHandler.java:76) 
[92t0@trydev.activeeon.com;11:16:11] at org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor.execute(InProcessTaskExecutor.java:198) 
[92t0@trydev.activeeon.com;11:16:11] ... 3 more 
Setrino commented 7 years ago

Same problem. Were you able to resolve it?

fviale commented 7 years ago

Unfortunately, not yet.