[
https://issues.apache.org/jira/browse/GROOVY-4895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Sun reassigned GROOVY-4895:
----------------------------------
Fix Version/s: 7.0.0-alpha-1
Assignee: Daniel Sun
> 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
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 7.0.0-alpha-1
>
>
> 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
(v10.3.26#10030026)