title: Grails cannot load oracle.jdbc.driver.OracleDriver and --refresh-dependencies does not work
body: <p>I get <strong>ClassNotFoundException</strong>: <code>oracle.jdbc.OracleDriver</code> any time I do a grails run-app without having done --refresh-dependencies immediately prior (I have the oracle driver .jar in my project /lib).</p>
  
  <p>I have seen similar questions <a href="https://stackoverflow.com/questions/11314664/groovy-grails-cannot-load-oracle-jdbc-driver-oracledriver">here</a> and elsewhere, and the answer always seems to be to run --refresh-depdencies</p>
  
  <p>However, I find that doing this only works for exactly one time after --refresh-dependencies is run. Any subsequent time I do run-app I get the <strong>ClassNotFoundException</strong>: <code>oracle.jdbc.OracleDriver</code> again, until I once again run --refresh-dependencies. By running --refresh-dependencies every time I am about to run-app I can still function, but it is quite annoying.</p>
  
  <p>I am running grails 2.3.0.</p>
  
  <p>grails output without having done --refresh-dependencies immediately prior to run-app:</p>
  
  <pre><code>| Loading Grails 2.3.0
  | Configuring classpath.
  | Environment set to development.....
  | Packaging Grails application.....
  | Running Grails application
  Configuring Spring Security Core ...
  ... finished configuring Spring Security Core
  Configuring Spring Security LDAP ...
  ... finished configuring Spring Security LDAP
  Configuring Spring Security CAS ...
  ... finished configuring Spring Security CAS
  | Error 2014-01-14 15:15:14,235 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: oracle.jdbc.OracleDriver
  Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: oracle.jdbc.OracleDriver
      Line | Method
  -&gt;&gt;  334 | innerRun  in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    166 | run       in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . in java.lang.Thread
  Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: oracle.jdbc.OracleDriver
  -&gt;&gt;  334 | innerRun  in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    166 | run       in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . in java.lang.Thread
  Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: oracle.jdbc.OracleDriver
  -&gt;&gt;  334 | innerRun  in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    166 | run       in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . in java.lang.Thread
  Caused by BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: oracle.jdbc.OracleDriver
  -&gt;&gt;  334 | innerRun  in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    166 | run       in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . in java.lang.Thread
  Caused by BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: oracle.jdbc.OracleDriver
  -&gt;&gt;  334 | innerRun  in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    166 | run       in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . in java.lang.Thread
  Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: oracle.jdbc.OracleDriver
  -&gt;&gt;  334 | innerRun  in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    166 | run       in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . in java.lang.Thread
  Caused by SQLException: oracle.jdbc.OracleDriver
  -&gt;&gt;  334 | innerRun  in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    166 | run       in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . in java.lang.Thread
  Caused by ClassNotFoundException: oracle.jdbc.OracleDriver
  -&gt;&gt;  175 | findClass in org.codehaus.groovy.tools.RootLoader
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    423 | loadClass in java.lang.ClassLoader
  |    147 | loadClass in org.codehaus.groovy.tools.RootLoader
  |    356 | loadClass in java.lang.ClassLoader
  |    266 | forName . in java.lang.Class
  |    334 | innerRun  in java.util.concurrent.FutureTask$Sync
  |    166 | run . . . in java.util.concurrent.FutureTask
  |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
  |    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
  
  ^    722 | run       in java.lang.Thread
  </code></pre>
  
  <p>and right after doing --refresh-dependencies:</p>
  
  <pre><code>| Loading Grails 2.3.0
  | Configuring classpath.
  | Environment set to development.....
  | Packaging Grails application.....
  | Running Grails application
  Configuring Spring Security Core ...
  ... finished configuring Spring Security Core
  Configuring Spring Security LDAP ...
  ... finished configuring Spring Security LDAP
  Configuring Spring Security CAS ...
  ... finished configuring Spring Security CAS
  | Server running. Browse to http://localhost:8080/loggity-rest
  </code></pre>