Skip to content

GRAILS-10562: Cannot find class com.mysql.jdbc.Driver #6005

@graemerocher

Description

@graemerocher

Original Reporter: tim_yates
Environment: Not Specified
Version: 2.3
Migrated From: http://jira.grails.org/browse/GRAILS-10562

If you add {{mysql:mysql-connector-java:5.1.24}} as a runtime dependency, you cannot gain access to {{com.mysql.jdbc.Driver}} from within the Bootstrap

Steps to reproduce:

  1. Create a new grails project
  2. Uncomment the line {{runtime 'mysql:mysql-connector-java:5.1.24'}} in {{Build.groovy}}
  3. Add {{Class.forName( 'com.mysql.jdbc.Driver' )}} to the {{init}} Closure in {{BootStrap.groovy}}
  4. {{grails run-app}}

It crashes with:

{code}
Error initializing the application: com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName(Class.java:190)
at BootStrap$_closure1.doCall(BootStrap.groovy:6)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

{code}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions