marko
marko

Reputation: 3776

Can't run Grails war-file on Tomcat

I'm able to build a war-file in STS, but I'm not able to deploy! Grails version 2.1.1.

I have read all kinds of posts, I have ran clean, update, compile, run-app (runs fine), upgraded Java, changed db-drivers (postgresql:postgresql:9.3-1100.jdbc41), removed test from the source path, changed grails.servlet.version to 3.0, to name a few.

My setup is pretty vanilla at the moment, so no mystical plugins.

When I try to deploy it using Tomcat or run grails run-war I get the following error:

Dec 23, 2013 11:39:10 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Dec 23, 2013 11:39:12 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Dec 23, 2013 11:39:17 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class             org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
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.DefaultGrailsControllerClass    at     com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
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:744)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
... 5 more
Caused by: java.lang.reflect.InvocationTargetException
... 5 more
Caused by: java.lang.NoClassDefFoundError: Lgrails/test/mixin/domain/DomainClassUnitTestMixin;
at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
at java.lang.Class.getDeclaredFields(Class.java:1806)
... 5 more
Caused by: java.lang.ClassNotFoundException: grails.test.mixin.domain.DomainClassUnitTestMixin
... 7 more

Upvotes: 1

Views: 3522

Answers (2)

Daniel Wondyifraw
Daniel Wondyifraw

Reputation: 7723

If u really need to test the .war ,but i suppose your grails run-app command carried out successfully and application is running. Isn't? If it is!! I suggest you do the following :

I suggest also the above error is a configuration problem to grails and tomcat on STS environment it self...seems to me...so ,

1. Install `Tomcat 6` Outside for Testing the `.war` after generating using grails console and the command below

2.  Instead of running the war directly from the grails console try to generate a Test ,Development or a production environment `.war` package as follow .

N.B You need to have Environment Specific setting for Deployment in your config.groovy file under grails conf folder..

continued ...

grails -Dgrails.env=development war

or ,Simply

 grails deve war    //here deve is referring to development environment u can do same for test and prod...

So.After you have successfully carried out the above steps ...it is time for you to collect you grains into a jar...so find the place of the war generated it is under targets folder on your created grails application folder.

So ,after that start manually or automatically started TOmcat6/7.goto webapps server and copy the package you generated above...first Stop Running Tomcat Server if any!....Cheers!

Upvotes: 0

marko
marko

Reputation: 3776

For the record.

What I did was copy:

grails-plugin-testing-2.1.1.jar
grails-test-2.1.1.jar
grails-test-suite-base-2.1.1.jar

(Can be found in GRAILS_HOME/dist)

to Forrest/lib and this to my Config.groovy:

grails.war.dependencies = [
    "grails-plugin-testing-2.1.1.jar",
    "grails-test-2.1.1.jar",
    "grails-test-suite-base-2.1.1.jar"
]

After that I did clean, compile, and run-war.

I was under the impression that test/prod were kept separated as I don't want my war-file to contain anything related to test.

Upvotes: 1

Related Questions