Ryan Flood
Ryan Flood

Reputation: 198

Groovy/Grails cannot load oracle.jdbc.driver.OracleDriver

I am trying to test a grails app connecting to a sql server, for now, I am using one of my own. This is my datasource.groovy

    dataSource {
        configClass = GrailsAnnotationConfiguration.class
        pooled = true
        driverClassName = "oracle.jdbc.driver.OracleDriver"
        dialect = "org.hibernate.dialect.Oracle10gDialect"
        dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
        url = "jdbc:oracle:thin:@127.0.0.1:1521/xe"
        username = "blah"
        password = "blah"
        properties {
            validationQuery="select 1 from dual"
            testWhileIdle=true
            timeBetweenEvictionRunsMillis=60000
        }
    }

I have borrowed this code from a different app, just changing the url and user/password. The other app runs fine, but my app throws a long exception, which boils down to this

Caused by SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
stack trace
Caused by ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I have copied ojdbc6.jar into my app lib/ but I am afraid I am lost on what to do next.

EDIT I have updated oracle.jdbc.driver.OracleDriver to oracle.jdbc.OracleDriver, but no progress

Upvotes: 1

Views: 12505

Answers (3)

Ryan Flood
Ryan Flood

Reputation: 198

So, turns out the problem was what @tim_yates suggested. The problem that I had since then was that even though I was refreshing the dependencies, as @burt said, but I had never re-loaded the config files.

I just ran grails clean then grails compile --refresh-dependencies and voila, problem solved. Thanks to @burt and @tim_yates for helping me out

Upvotes: 3

Burt Beckwith
Burt Beckwith

Reputation: 75671

Run

grails compile --refresh-dependencies

when you add a jar to the lib directory so Grails adds it to the classpath. This is a new requirement in 2.0+

Unrelated - you can remove

configClass = GrailsAnnotationConfiguration.class

since that's the default now

Upvotes: 5

tim_yates
tim_yates

Reputation: 171104

Shouldn't the class be:

driverClassName = "oracle.jdbc.OracleDriver"

I believe the other one was deprecated

Upvotes: 4

Related Questions