Using: GG ver 2.2.4; and Groovy/Grails Tool Suite Version: 3.3.0.RELEASE
Here's the question: How do I get a specific Grails JAR into the WAR built with GGTS?
As side questions, why doesn't the WAR get that JAR packaged into it? And why does "grails run-app" work just fine, but deploying the WAR (in Development or Production) fails?
Here's the background:
When I run "grails run-war" locally on my Windows 7 deveopement computer, it fails with:
2013-10-16 11:36:05,371 [localhost-startStop-1] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: grails/test/mixin/domain/DomainClassUnitTestMixin
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
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)
**Caused by: java.lang.NoClassDefFoundError: grails/test/mixin/domain/DomainClassUnitTestMixin**
When I run "grails war" and then deploy the Production WAR to Tomcat 6 on my server, I get a similar deployment error inside catalina.out:
INFO | jvm 1 | 2013/10/16 17:03:47 | Oct 16, 2013 5:03:47 PM org.apache.catalina.core.ApplicationContext log
INFO | jvm 1 | 2013/10/16 17:03:47 | INFO: HTMLManager: start: Starting web application at '/TSWeb-0.1'
INFO | jvm 1 | 2013/10/16 17:03:48 | Oct 16, 2013 5:03:48 PM org.apache.catalina.core.ApplicationContext log
INFO | jvm 1 | 2013/10/16 17:03:48 | INFO: Initializing Spring root WebApplicationContext
INFO | jvm 1 | 2013/10/16 17:03:49 | 2013-10-16 17:03:49,388 [TP-Processor2] ERROR context.ContextLoader - Context initialization failed
INFO | jvm 1 | 2013/10/16 17:03:49 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: grails/test/mixin/support/GrailsUnitTestMixin
INFO | jvm 1 | 2013/10/16 17:03:49 | at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
INFO | jvm 1 | 2013/10/16 17:03:49 | at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:311)
INFO | jvm 1 | 2013/10/16 17:03:49 | at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
INFO | jvm 1 | 2013/10/16 17:03:49 | at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
INFO | jvm 1 | 2013/10/16 17:03:49 | at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
INFO | jvm 1 | 2013/10/16 17:03:49 | at java.lang.Thread.run(Thread.java:724)
INFO | jvm 1 | 2013/10/16 17:03:49 | **Caused by: java.lang.NoClassDefFoundError: grails/test/mixin/support/GrailsUnitTestMixin**
INFO | jvm 1 | 2013/10/16 17:03:49 | at java.lang.Class.forName(Class.java:270)
I can explore inside the WAR, and see that WEB-INF/lib/ does NOT contain the JAR in which both of the above classes reside (grails-plugin-testing-2.2.4.jar).
I tried putting
grails.war.dependencies = [
"grails-plugin-testing-2.2.4.jar"
]
into config.groovy and this did not work. The WAR still did not contain that JAR and I got the same error.
So, I just put grails-plugin-testing-2.2.4.jar into the WEB-INF/lib folder on the server and re-deployed and verified that the error above goes away, but now I get another error on the server:
INFO | jvm 1 | 2013/10/16 18:34:02 | Oct 16, 2013 6:34:02 PM org.apache.catalina.core.ApplicationContext log
INFO | jvm 1 | 2013/10/16 18:34:02 | INFO: HTMLManager: start: Starting web application at '/TSWeb-0.1'
INFO | jvm 1 | 2013/10/16 18:34:03 | Oct 16, 2013 6:34:03 PM org.apache.catalina.core.ApplicationContext log
INFO | jvm 1 | 2013/10/16 18:34:03 | INFO: Initializing Spring root WebApplicationContext
INFO | jvm 1 | 2013/10/16 18:34:07 | 2013-10-16 18:34:07,011 [TP-Processor12] ERROR context.ContextLoader - Context initialization failed
INFO | jvm 1 | 2013/10/16 18:34:07 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsBootstrapClass
INFO | jvm 1 | 2013/10/16 18:34:07 | at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
INFO | jvm 1 | 2013/10/16 18:34:07 | at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:311)
INFO | jvm 1 | 2013/10/16 18:34:07 | at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
INFO | jvm 1 | 2013/10/16 18:34:07 | at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
INFO | jvm 1 | 2013/10/16 18:34:07 | at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
INFO | jvm 1 | 2013/10/16 18:34:07 | at java.lang.Thread.run(Thread.java:724)
INFO | jvm 1 | 2013/10/16 18:34:07 | Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsBootstrapClass
INFO | jvm 1 | 2013/10/16 18:34:07 | ... 6 more
INFO | jvm 1 | 2013/10/16 18:34:07 | Caused by: java.lang.reflect.InvocationTargetException
INFO | jvm 1 | 2013/10/16 18:34:07 | ... 6 more
INFO | jvm 1 | 2013/10/16 18:34:07 | Caused by: java.lang.NoClassDefFoundError: grails/test/GrailsMock
INFO | jvm 1 | 2013/10/16 18:34:07 | at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
INFO | jvm 1 | 2013/10/16 18:34:07 | at java.lang.Class.getDeclaredMethods(Class.java:1845)
INFO | jvm 1 | 2013/10/16 18:34:07 | ... 6 more
INFO | jvm 1 | 2013/10/16 18:34:07 | Caused by: java.lang.ClassNotFoundException: grails.test.GrailsMock
INFO | jvm 1 | 2013/10/16 18:34:07 | ... 8 more
I'll investigate the second error and ask about it in a different question and reference it here. [UPDATE: This error goes away if I also put grails-test-2.2.4.jar into WEB-INF/lib on the server. Then, the WAR deploys and runs successfully.]
To keep this Question/Answer to one topic, how do I get these 2 JARs into the WAR?
But, of course, perhaps there is ONE solution that would solve BOTH issues (he-he-he - not likely but worth mentioning!) For example, I am ignorant as to why grails-plugin-testing-2.2.4.jar is used. Perhaps there is a setting I need to change to have that "go away."
THANKS!