When I build a grails 2.1.0 app with the tomcat 2.2.0 I get the following error on startup when I deploy on Tomcat 7:
INFO: validateJarFile(/app/app/webapps/ROOT/WEB-INF/lib/tomcat-embed-core-7.0.27.jar) – jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Dec 1, 2012 4:01:01 PM org.apache.catalina.core.NamingContextListener lifecycleEvent
SEVERE: Creation of the naming context failed: javax.naming.NamingException: Context is read only
and
java.lang.NoClassDefFoundError: org/apache/tomcat/PeriodicEventListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1128)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
If I delete the tomcat-* jar files in the exploded war the app starts without a problem, or if I remove the tomcat plugin the app starts without a problem.
Ideally I would like to build the app without the plugin but have for development purposes. Is this possible?
For starters, use the version of the Tomcat plugin that corresponds to the version of Grails you’re using. The real problem though is that the plugin should only be available in development for the
run-appandrun-warscripts, but shouldn’t end up in the WAR file created by thewarscript. If you have the plugin in application.properties, remove it (along with any other plugins that are there). This puts the plugin incompilescope and will lead to it being in the WAR file.The correct way to use the plugin is to add a
buildscope dependency in thepluginssection ofBuildConfig.groovy: