I am attempting to get my grails application running locally with tomcat, but without placing ojdbc6.jar in /lib. My grails application is deployed to Glassfish and works fine on the server (because the ojdbc6.jar is available there). As expected the error is:
Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]
(Failed) Approach #1
I first customized my GGTS run-configuration to include the VM arguments:
-cp :/somelocalpath/oracle-jdbc-drivers
However the error persisted.
(Failed) Approach #2
I'm currently looking to use the jvmArgs to point to a local version of the jar.
grails.tomcat.jvmArgs = ["-cp:/somelocalpath/oracle-jdbc-drivers/ojdbc6.jar"]
However a run-war results in:
| Error Server failed to start: tomcat exited prematurely with code '1' (error output: 'Unrecognized option: -cp:/apps/glassfish3/oracle-jdbc-drivers/ojdbc6.jar
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
')
I should clarify my main focus - I do not want the jar to be included in the final war.
Any help would be appreciated. Thanks!
From the documentation:
grails.war.resources lets you do any extra processing you want before the WAR file is finally created.
In your case, you need to add something like that to your build config to exclude the Jar of the final WAR.
grails.war.resources = { stagingDir ->
delete(file:"${ stagingDir }/WEB-INF/lib/yourJarFile.jar")
}