Questions tagged [groovyclassloader]

GroovyClassLoader is a ClassLoader for loading Groovy classes.

GroovyClassLoader is a ClassLoader for loading Groovy classes.

39 questions
18
votes
4 answers

Run groovy script from within gradle

What's the best way to create a gradle task, which runs a groovy script? I realize that gradle build files are groovy, so I would think it would be possible to do something like this: task run << { Script app = new GroovyShell().parse(new…
macattack
  • 181
  • 1
  • 3
6
votes
1 answer

GroovyClassLoader call to parseClass is successful, even when code does not compile

I'm trying to dynamically load a Groovy script as a class but the class object is created even when the script's code does not compile. For example, a simplified version of my Groovy code to load the Groovy script is as follows: GroovyCodeSource src…
entpnerd
  • 10,049
  • 8
  • 47
  • 68
5
votes
1 answer

How can I execute groovy scripts in an isolated classloader?

I'm trying to run groovy scripts in an isolated classloader so that they are not executed in the context of the calling class' dependencies. Path log4j = Paths.get("..../lib/log4j-1.2.17.jar"); Path groovy =…
jordanpg
  • 6,386
  • 4
  • 46
  • 70
5
votes
1 answer

GroovyShell in Java8 : memory leak / duplicated classes [src code + load test provided]

We have a memory leak caused by GroovyShell/ Groovy scripts (see GroovyEvaluator code at the end). Main problems are (copy-paste from MAT analyser): The class "java.beans.ThreadGroupContext", loaded by "", occupies…
Patrycja K
  • 731
  • 7
  • 14
5
votes
1 answer

GroovyClassLoader and imports

I am using a GroovyClassLoader in my Java class to parse a certain (ideally complex) groovy file (to be executed in the next step): Call in MyClass.java final Class parsedClass = groovyClassLoader.parseClass(groovyFile); Knowing that: Groovy files…
Antonio Acevedo
  • 1,480
  • 3
  • 21
  • 39
4
votes
2 answers

Loading classes not present in the classpath

Let's say I've compiled a Groovy script using Groovyc, which has generated one or more .class files in the file system. From a Java application, how do I add those classes to the classpath dynamically in order to load them and call their methods?…
Tiago Fernandez
  • 1,453
  • 3
  • 19
  • 36
4
votes
1 answer

Adding IntegerMetaClass to GroovyShell dynamically

I would like to use a custom IntegerMetaClass only in a given GroovyShell context. The reason why is to not pollute the whole runtime with my potentially 'disturbing' IntegerMetaClass. It works like a charm when I put my IntegerMetaClass.java…
3
votes
1 answer

Beanshell will not allow me to add jars to the "default" JRE classloader?

I have a question about Beanshell that I can't find an answer to anywhere. I am only able to run Beanshell scripts in 1 of 2 ways: Where Classpath is defined before invoking Beanshell and Beanshell uses the JRE default classloader. Where no…
djangofan
  • 28,471
  • 61
  • 196
  • 289
3
votes
1 answer

How can I evaluate my own Groovy script from Java?

I try to call my own groovy script function from Java class and also user can use standart expressions. For Example: GroovyShell shell = new GroovyShell(); Script scrpt = shell.parse("C:/Users/Cagri/Desktop/MyCustomScript.groovy"); Binding binding…
cgrgcn
  • 361
  • 2
  • 6
  • 24
2
votes
0 answers

How to Store the Compiled Groovy Script in Database and can be fetched when needed?

I have an application which use the same groovy script for multiple times. Everytime, it compiles the same script again and again during runtime. In order to improve the performance, I need to compile the script only once and store the compiled…
2
votes
2 answers

Groovy: re-compile a class from file and memory leaks

As per ref-doc: A GroovyClassLoader keeps a reference of all the classes it created, so it is easy to create a memory leak. In particular, if you execute the same script twice, if it is a String, then you obtain two distinct classes! I use a file…
injecteer
  • 20,038
  • 4
  • 45
  • 89
2
votes
4 answers

Groovy dynamically invoked class and find method doesn't work?

I trying to build a dynamic query similar to: def domain = DomainName def ids = 1 def domainClass = "$domain" as Class domainClass.find("from ${domain} as m where m.job = ${ids} ").id But it's not working. If I'm trying this, all is fine: def…
Fabien Barbier
  • 1,514
  • 4
  • 28
  • 41
1
vote
1 answer

Grails 1.4.0.M1 (with STS 2.7.0.M2) NoClassDefFoundError for GantBuilder

I have just upgraded to... Grails 1.4.0.M1 Groovy 1.8.0 STS Version: 2.7.0.M2 Build Id: 201106101000 - 64bit Cocoa version for Mac I have OS X 10.5.8. with JVM 1.5.0 When I run a grails command eg 'create-app' or 'upgrade' on an existing project…
Chris
  • 3,552
  • 2
  • 26
  • 36
1
vote
0 answers

How do I confirm that I don't have duplicate classes within my ClassLoader structure?

I'm using a GroovyClassLoader to load multiple groovy files (not scripts) that have Class names and package structures. I believe I'm running into an issue of multiple Class files being loaded for the same Class, despite calling parseClass only once…
1
vote
0 answers

No suitable ClassLoader found for grab wenn starting from SCM jenkins pipeline

Why if i run pipeline script there is no problem, and if i run it from SCM i get No suitable ClassLoader found for grab How can I fix this?
rikkatti
  • 706
  • 1
  • 8
  • 14
1
2 3