Daniel Henrique Alves Lima | 1 Jun 2011 11:51
Picon
Favicon
Gravatar

Re: [groovy-user] Re: JDBC driver fails to work after registering

    Hi.

dmantampfl wrote:
> Thanks. But I am still having issues understanding the different classloaders
> used by groovy and the need for it.
>
> Why should groovy use a different class loader when I specify what class
> loader to use.
This is not a Groovy issue. Some classes of the Java core libraries uses 
callerClassLoader or Class.forName(String).

>  The CallSiteClassLoader groovy uses is not create by JVM.
> This is the "callerClassLoader" the driver manager sees.
>   
I don't think this is true. I honestly believe that callerClassLoader is 
the systemClassLoader in this case, but you're probably waiting for 
confirmation of a Groovy guru (which I'm not).

> May be I am totally wrong here. But I wanted to get some confirmation.
>
>
>   
Have you tried my test project from the other thread?

I changed the run.groovy and I made a quick test:

http://pastie.org/2002572

[daniel <at> techdm groovy_cl2]$ groovy run.groovy
== cl groovy.lang.GroovyClassLoader$InnerLoader <at> 56d90453 ==
driverClass class org.postgresql.Driver
driverClass.classLoader groovy.lang.GroovyClassLoader <at> 44050988
error No suitable driver found for jdbc:postgresql:testdb
== cl groovy.lang.GroovyClassLoader <at> 44050988 ==
driverClass class org.postgresql.Driver
driverClass.classLoader groovy.lang.GroovyClassLoader <at> 44050988
error No suitable driver found for jdbc:postgresql:testdb
== cl sun.misc.Launcher$AppClassLoader <at> 5acac268 ==
driverClass class org.postgresql.Driver
driverClass.classLoader sun.misc.Launcher$AppClassLoader <at> 5acac268
error Connection refused. Check that the hostname and port are correct 
and that the postmaster is accepting TCP/IP connections.

[daniel <at> techdm groovy_cl2]$ groovy -cp libs/postgresql-8.4-702.jdbc4.jar 
run.groovy
== cl groovy.lang.GroovyClassLoader$InnerLoader <at> 65d0d124 ==
driverClass class org.postgresql.Driver
driverClass.classLoader org.codehaus.groovy.tools.RootLoader <at> 7000a32b
error Connection refused. Check that the hostname and port are correct 
and that the postmaster is accepting TCP/IP connections.
== cl groovy.lang.GroovyClassLoader <at> 11a06e38 ==
driverClass class org.postgresql.Driver
driverClass.classLoader org.codehaus.groovy.tools.RootLoader <at> 7000a32b
error Connection refused. Check that the hostname and port are correct 
and that the postmaster is accepting TCP/IP connections.
== cl sun.misc.Launcher$AppClassLoader <at> 5acac268 ==
driverClass class org.postgresql.Driver
driverClass.classLoader sun.misc.Launcher$AppClassLoader <at> 5acac268
error Connection refused. Check that the hostname and port are correct 
and that the postmaster is accepting TCP/IP connections.
[daniel <at> techdm groovy_cl2]$

In the latter case, org.postgresql.Driver is loaded by RootLoader and 
AppClassLoader, but DriverManager only "sees" the version loaded by the 
AppClassLoader.

http://grails-batch-launcher-plugin.googlecode.com/files/groovy_cl2.tar.bz2

    Best regards,

            Daniel.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane