groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (GROOVY-4895) GroovyShell uses a different class loader than the one that I have specified.
Date Thu, 03 Aug 2017 23:17:00 GMT

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

Paul King edited comment on GROOVY-4895 at 8/3/17 11:16 PM:
------------------------------------------------------------

The CallSiteClassLoader is needed for call site caching. Normally that loader will delegate
to the script's loader, which should be a child of the loader you set.


was (Author: blackdrag):
The CallSiteClassLoader is needed for call site caching. Normally that loader will delegat
to the script's loader, which should be a child of the loader you set.

> GroovyShell uses a different class loader than the one that I have specified.
> -----------------------------------------------------------------------------
>
>                 Key: GROOVY-4895
>                 URL: https://issues.apache.org/jira/browse/GROOVY-4895
>             Project: Groovy
>          Issue Type: Bug
>         Environment: Generic
>            Reporter: dmantampfl
>
> I have an application in which I am calling a groovy script. The application uses a custom
class loader, because I have to load some of jars dynamically, including the jdbc drivers.
I am using this class loader in the constructor of GroovyShell(). Here is snippet of my script
> Class.forName("<JDBC driver>");
> connection = DriverManager.getConnection(url,...)
> When I run the script using shell.evaluate(), the driver is registered properly. I know
it because, it didn't throw any exception and I have added trace statements in JDK code as
well. But when I create the connection it fails with error
> java.sql.SQLException: No suitable driver found for ....
> I listed the registered drivers from DriverManager, it didn't show the jdbc driver I
registered earlier. When I debugged the DriverManager, I found that the 'caller' classloader
is totally different. It is 'CallSiteClassLoader' which is groovy specific. But the script
registered the jdbc driver with the classloader I specified in the groovyShell constructor.
> Groovy should not use its own class loader when I specify a class loader. Or at least
it should use my class loader as parent.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message