Questions tagged [groovyclassloader]

GroovyClassLoader is a ClassLoader for loading Groovy classes.

GroovyClassLoader is a ClassLoader for loading Groovy classes.

39 questions
1
vote
0 answers

Replace classpath of a running Groovy Script (Jenkins Pipeline script)

In Jenkins Pipeline we have a CpsGroovyScript executed by CPSGroovyShell with a custom classpath which is appended with path to Global Library location. In order to be able to test my changes before making them available for all the Pipelines on my…
izzekil
  • 5,781
  • 2
  • 36
  • 38
1
vote
1 answer

How compile Groovy source but not from filesystem

I compile single groovy source module "in fly" using GroovyClassLoader.parseClass(src) and all is ok. But problem is when this source module imports other classes, these are not compiled yet. Traditional compiling when I start compilation of one…
Jacek Cz
  • 1,872
  • 1
  • 15
  • 22
1
vote
1 answer

How to use import inside a dynamically loaded groovy file

I am trying to come up with a way for my users to supply plugins into the main groovy application by dynamically loading their source file. But their groovy file contains import statements and I don't know how to make them work even with an…
user1241663
  • 191
  • 1
  • 11
1
vote
1 answer

GroovyClassLoading Mechanism

I'm really newbie to groovy scripting but following some tutorial I tried to dynamically load some groovy class within my java code using parseClass() method of GroovyClassLoader. I wrote some snippet and it worked fine for me. The problem is that I…
tmarwen
  • 15,750
  • 5
  • 43
  • 62
1
vote
1 answer

GroovyClassLoader parseClass security

I'm building a Grails application that allows a user to write Groovy code, which then gets executed within my framework. This, of course, is a massive security threat, as the user could enter malicious code. The Groovy classes are being compiled…
djh
  • 95
  • 1
  • 1
  • 7
1
vote
2 answers

What are the pros and cons of using GroovyClassLoader vs. GroovyShell

I need to run some external code from my Java application that will be updated frequently and orthogonally to the rest of the application. As I do not to re-deploy the entire application for every code change (and for other reasons as well) we chose…
David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125
0
votes
1 answer

GroovyClassloader behaviour

GroovyClassloader behaviour understanding , ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("groovy"); GroovyScriptEngineImpl groovyEngineImpl = (GroovyScriptEngineImpl) engine; in a loop, for…
anish
  • 6,884
  • 13
  • 74
  • 140
0
votes
1 answer

lookupScriptFiles "true" in the loadClass() method

Extended GroovyClassloader and override loadclass method If I make lookupScriptFiles "true" in the loadClass() method the script run and doesn't require an import statement referencing a groovy class in a different package i have extended…
anish
  • 6,884
  • 13
  • 74
  • 140
0
votes
1 answer

Missing Jenkins functions inside loaded groovy class

I am loading external groovy class file using evaluate readTrusted("class_file.groovy") everything is working fine untill I am running jenkins pipeline functions like dir() or checkout() then I am getting. hudson.remoting.ProxyException:…
0
votes
0 answers

How to use the `addClasspath()` method in GroovyClassLoader

I need to load a bunch of groovy scripts from DataBase , like this: List scriptList = dataBaseRepository.findAll(); GroovyClassLoader groovyClassLoader = new GroovyClassLoader(this.getClass().getClassLoader()); for (ScriptDAO script :…
euphon
  • 1
0
votes
1 answer

How to use GroovyClassLoader to load GroovyCompiled classes or how to set delegate in case of loadClass

I am trying to loadClass which are compiled during build and placed in classpath as .class files. For this I tried GroovyClassLoader gos = new GroovyClassLoader(); gos.loadClass("className"); This will successfully load the class file in java code…
Ashish
  • 1
  • 2
0
votes
2 answers

Java : GroovyClassLoader : cannot find symbol for method in Groovy Class

I am trying to use GroovyClassLoader in java to execute a method in Groovy Class. I have created a Java Class, pubic method which creates a instance of GroovyClassLoader , parseClass and then creates a new Instance of the class, Calls a method in…
gnsandeep
  • 25
  • 5
0
votes
1 answer

Groovy class can't locate superclass in the same package

I have a few groovy classes in the same package ( com.company.config ) in a multi-modular java-8 project. All used to inherit a java interface ( MyInterface ), but some refactoring was needed so I created a groovy abstract class which resides in the…
payloc91
  • 3,724
  • 1
  • 17
  • 45
0
votes
1 answer

GroovyCastException while running java code containing new line "\n" with groovy script engine(GroovyClassLoader)

Currently I am working on a way to run java code in string form. So here is how I did it. import java.util.HashMap; import java.util.Map; import groovy.lang.GroovyClassLoader; public class GroovyStackOverflow { public static void…
0
votes
1 answer

Cannot dynamically change or add methods in a class using GroovyClassLoader

I try to dynamically change and add methods of a class defined in a groovy script from another groovy script but cannot figure out why it works if I use the classname directly in .metaClass. but not if I load the class using the…
Franck Valentin
  • 1,115
  • 8
  • 14