Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jpokrzyk opened this issue Dec 28, 2013 · 4 comments
Open

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

jpokrzyk opened this issue Dec 28, 2013 · 4 comments
Assignees

Comments

@jpokrzyk
Copy link

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.

@ghost ghost assigned LostInBrittany Jan 13, 2014
@LostInBrittany
Copy link
Contributor

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
Copy link

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
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants