I'm using Grails 2.3.5 on Windows and have created the project using grails create-app command from the command line. When I run grails run-app --verbose from the command line I get the exception below.
Caching deactivated: failed to create cache directory: C:/grails/2.3.5/
java.lang.NoClassDefFoundError: org/apache/catalina/startup/Tomcat
at...
Caused by: java.lang.ClassNotFoundException: org.apache.cataliina.startup.Tomcat
Below is my part of my BuildConfig.groovy file
...
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
//compile 'xlan:serializer:jar:2.7.1'
// runtime 'mysql:mysql-connector-java:5.1.27'
// runtime 'org.postgresql:postgresql:9.3-1100-jdbc41'
//These were added for mongodb
compile 'org.grails:grails-datastore-gorm:3.1.0.RELEASE'
compile 'org.grails:grails-datastore-core:3.1.0.RELEASE'
test 'org.grails:grails-datastore-simple:3.1.0.RELEASE'
compile "net.sf.ehcache:ehcache-core:2.4.6"
compile 'org.grails:grails-async:jar:2.3.8'
compile 'org.springframework:spring-tx:3.2.8.RELEASE'
}
plugins {
// plugins for the build system only
//build ":serializer:2.7.1"
build ':tomcat:7.0.50'
// plugins for the compile step
compile ":scaffolding:2.0.1"
//compile ':cache:1.1.1'
compile ':mongodb:3.0.1'
compile ":jquery-ui:1.10.3"
compile ":spring-security-core:2.0-RC4"
// plugins needed at runtime but not for compilation
// runtime ":hibernate:3.6.10.7" // or ":hibernate4:4.1.11.6"
runtime ":database-migration:1.3.8"
runtime ":jquery:1.10.2.2"
runtime ":resources:1.2.1"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0.1"
//runtime ":cached-resources:1.1"
//runtime ":yui-minify-resources:0.1.5"
}...
I am running this grails offline mode pointing to a local repository. This only compiled successfully after I added the jars listed below to my lib folder in my Groovy/Grails tool suite folder so that they would be in the classpath (this fixed the TomcatKillSwitch error in catalina)
- catalina.jar
- catalina-ant.jar
- catalina-ha.jar
- catalina-tribes.jar
- tomcat-api.jar
- tomcat-coyote.jar
- tomcat-util.jar
Why cant grails find Tomcat and why can't it create a cache?
Delete those jar files; you may have 'fixed' this problem, but you really just hid a symptom and the problem still exists, and will resurface, likely the next time you add a plugin. Go ahead and delete the lib directory too - it will probably just continue to tempt you with its presence.
It seems to me that the core problem is simple and clearly stated; Grails wasn't able to create
C:/grails/2.3.5/
. The side effects were not clearly stated, and one of them was that Grails wasn't able to properly unpack the Tomcat plugin (and probably others also) and augment the classpath with its source and jar dependencies.A proper fix for this issue would be to upgrade to a sensible OS. I suggest Linux, others find comfort in being part of a large group of eerily like-minded 'individuals' and would suggest OSX, but really anything but Windows will do.
I'm going to go out on a limb here and claim that you can end this dark period of cache-poverty if you were to undertake the mission of manually creating
c:\grails
. By default you can't create files or directories in the root of the C: drive in recent versions of Windows; of course it's possible, and you'll be asked far too many "are you sure"-type questions along this journey, but it can done.You'd then be cache-rich after restarting because Grails would be able to create the 2.3.5 directory, unpack the plugins, and refer to previously downloaded/cached Tomcat jars programmatically instead of having to have them in the lib directory.