Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I set an embedded Groovy scripts classpath?
    primarykey
    data
    text
    <p>I am trying to extend an Eclipse code builder (for generating DTOs from Hibernate VOs) - and it uses Groovy for its template system. </p> <p>The code it uses to create the groovy Script is a little weird (not what I see in the Groovy docs) but it works, mostly:</p> <pre><code>GroovyShell shell = new GroovyShell(); script = shell.parse(source); </code></pre> <p>Then, later:</p> <pre><code>Binding binding = (bindings == null ? new Binding() : new Binding(bindings)); Script scriptInstance = InvokerHelper.createScript(script.getClass(), binding); scriptInstance.setProperty("out", out); scriptInstance.run(); out.flush(); </code></pre> <p>Now, this works just fine, until it hits a reference to an object that is not directly in the project. In the script, it iterates through the properties of the Class that it is processing - when it does this, Groovy looks at all of the methods and when it can't find a Class definition for one of the method parameters, it craps out. In this case, it's dying when it finds any references to Hibernate, but I'm sure it will crap out with a lot more. It doesn't need to do anything to them, but it can't live without knowing what they are apparently.</p> <p><a href="http://groovy.codehaus.org/api/groovy/lang/Script.html" rel="nofollow noreferrer">Script</a> doesn't appear to have a classloader that I can supply any classpath info, so I tried providing it to the <a href="http://groovy.codehaus.org/api/groovy/lang/GroovyShell.html" rel="nofollow noreferrer">GroovyShell</a> - no difference.</p> <p>What's the proper way to fix this so that the Groovy interpreter can find my projects referenced Jars?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload