vert-x / mod-lang-groovy

Vert.x 2.x is deprecated - use instead
https://github.com/vert-x3/vertx-lang-groovy
Other
16 stars 15 forks source link

Class loader doesn't seem to load JDBC drivers #44

Open jpokrzyk opened 10 years ago

jpokrzyk commented 10 years ago

Groovy class loader won't load JDBC drivers. See https://groups.google.com/forum/#!topic/vertx/djXxGfOClt0.

Here's some sample code to reproduce error: https://gist.github.com/jpokrzyk/8109151

Seems like this one is beyond my skill level to fix but if you don't get to it in a few days I'll take a look.

LostInBrittany commented 10 years ago

Having looked at it several evening this week, I haven't been able to solve it. I'll try again this week, and if I'm unable to solve it, I'll escalate to @purplefox

rodrigoSaladoAnaya commented 10 years ago

I tested and work fine, I can't reproduce the issue with a postgresql driver, e.g.: [https://gist.github.com/rodrigoSaladoAnaya/11063062]

The problem must be that the jar is not in the classpath, or that the jar you use has a problem.

If I have a mistake and instead of url:'jdbc: postgresql://localhost/databasname' I put something like url:'jdbc:postgresqlFoo://localhost/databasname' I get an exception:

Caused by: java.sql.SQLException: No suitable driver found for jdbc:postgresqlr://localhost/databasename
at java.sql.DriverManager.getConnection (DriverManager.java: 604) 
at java.sql.DriverManager.getConnection (DriverManager.java: 221) 
at groovy.sql.Sql.newInstance (Sql.java: 396) 
at groovy.sql.Sql.newInstance (Sql.java: 440) 
groovy.sql.Sql at $ newInstance.call (Unknown Source)
...

Regards.

rodrigoSaladoAnaya commented 10 years ago

Hi @jpokrzyk, you can add this snippet and verify that the driver is included?

//Show classpath elements
System.getProperty('java.class.path').split(':').each {
    println "> ${it}"
}

Regards.

jpokrzyk commented 10 years ago

K. I can't remember exactly how I was doing this originally. vertx runmod works fine if I put the jdbc.jar in the lib folder. Don't know if I previously tried that. I might have been trying to us grape.

I still can't get it to work with gradle. Here's the code: https://dl.dropboxusercontent.com/u/416599/gist.zip

Here's the classpath dump with vertx runmod

PS C:\Users\Jon\github\gist> vertx runmod com.carematics~test~1.0
> ;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\conf;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\hazelcast-2.6.7.jar;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\jackson-annotations-2.2.2.jar;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\jackson-core-2.2.2.jar;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\jackson-databind-2.2.2.jar;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\netty-all-4.0.17.Final.jar;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\vertx-core-2.1RC1.jar;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\vertx-hazelcast-2.1RC1.jar;C
> \Users\Jon\bin\vert.x-2.1RC1\bin\..\lib\vertx-platform-2.1RC1.jar

Here's the classpath from gradle runmod

> \Users\Jon\bin\gradle-1.11\bin\..\lib\gradle-launcher-1.11.jar

But feel free to close this if you don't want to work on it. If I'm using gradle, it's a larger-ish project and I would be using mod-jdbc anyways.

With 'vertx run' I was probably trying to do this with grape. And after thinking that one through definitely understand why vertx wouldn't pick up what grape downloads.

Thanks for te follow up though.