[ 
https://issues.apache.org/jira/browse/TORQUE-361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17696092#comment-17696092
 ] 

Georg Kallidis commented on TORQUE-361:
---------------------------------------

ok, it seems to me worth considering to change the code that the already 
configured classpath in UnitDescriptor might be used?

What if we initialize GroovyShell lazily, not statically using singleton 
pattern?

Pseudocode (in org.apache.torque.generator.template.groovy.GroovyScriptOutlet):
{code:java}
private static volatile GroovyShell groovyShell = null;

GroovyShell getInstance(ClassLoader cl) {
  if (groovyShell == null) {
     // might check also cl == null ?
     groovyShell = new GroovyShell(cl);
  } 
  return groovyShell;
}

executeGroovy(binding, controllerState)
    ..
    gs = getInstance(controllerState.getUnitConfiguration().getClassLoader())
    gs.parse ..


{code}
If this is feasible and consistent (the classpath in unit configuration is from 
unit descriptor and is exactly what we want to be used here) then I would ask 
you to try this and share here with us, what you prefer - this or another 
solution.

> Groovy can't resolve import from ddl scripts
> --------------------------------------------
>
>                 Key: TORQUE-361
>                 URL: https://issues.apache.org/jira/browse/TORQUE-361
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 5.0, 5.1
>            Reporter: Max Philipp Wriedt
>            Priority: Major
>              Labels: groovy
>
> The GroovyShell invoked at GroovyScriptOutlet.java:42 doesn't get a 
> classpath, if i try to start it from a gradle instance. (the generator is 
> invoked inside a kotlin.class)
> {code:java}
> Error executing template torque.sql.ddl.database
> org.apache.torque.generator.GeneratorException: Error executing template 
> torque.sql.ddl.database
> Caused by: org.apache.torque.generator.GeneratorException: Error executing 
> groovy script torque.sql.ddl.database
> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: 
> startup failed:
> Script1.groovy: 17: unable to resolve class 
> org.apache.torque.generator.template.groovy.TorqueGenGroovy
>  @ line 17, column 1.
>    import org.apache.torque.generator.template.groovy.TorqueGenGroovy
>    ^{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org

Reply via email to