My Grails app runs fine in Tomcat when the (MySQL) dataSource is defined in DataSource.groovy. But when using an external config file I get ClassNotFoundExceptions for the MySQL drivers from Tomcat. No special War dependencies are set up either.
I am probably missing something obvious, but cant seem to identify it. Tried moving the MySQL connector to the CATALINA_HOME/lib, but that doesn’t do it.
Any thoughts or help is greatly appreciated!
....
//loading external config
def extConfig = System.properties.getProperty("${appName}-config.location");
grails.config.locations = [ "file:${extConfig}/${appName}-config.properties"]
//config file contents.
dataSource.pooled = true
dataSource.dbCreate = "create-drop"
dataSource.driverClassName = "com.mysql.jdbc.Driver"
dataSource.username = "root"
dataSource.password = "ttech"
dataSource.url="jdbc:mysql://localhost:3306/registration"
In our projects we have an external properties file for configuration and we use it to set the datasource configuration as well, in our case we use PostgresSQL and we use the BuildConfig.groovy to include the jar file for the driver, when the WAR is generated Grails dependency management system puts the jar in WEB-INF/lib and that has worked just fine for us, no need to put in the Tomcat lib folder.
In your settings I see that you are not specifying the dialect for the datasource, you might want to check that in your external file too.
Hope this helps!