无法在Tomcat上运行Grails war-file

时间:2013-12-23 22:53:44

标签: tomcat grails grails-2.0

我能够在STS中构建一个war文件,但是我无法部署! Grails版本2.1.1。

我已经阅读了各种帖子,我已经运行了干净,更新,编译,运行应用程序(运行正常),升级了Java,更改了db-drivers(postgresql:postgresql:9.3-1100.jdbc41),删除了测试源路径,将grails.servlet.version更改为3.0,仅举几例。

我的设置目前非常香草,所以没有神秘的插件。

当我尝试使用Tomcat部署它或运行grails run-war时,我收到以下错误:

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

2 个答案:

答案 0 :(得分:1)

记录。

我做的是复制:

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

(可在GRAILS_HOME / dist中找到)

到Forrest / lib,这到我的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"
]

之后我做了清理,编译和战争。

我的印象是test / prod保持分离,因为我不希望我的war文件包含与测试相关的任何内容。

答案 1 :(得分:0)

如果您真的需要测试.war,但我认为您的grails run-app命令已成功执行且应用程序正在运行。是不是?如果是!!我建议你做以下事情:

我建议上面的错误是grails和tomcat在 STS 环境中的配置问题它自己...在我看来......所以,

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您需要在grails config.groovy文件夹下的conf文件中为部署设置环境特定设置..

继续......

grails -Dgrails.env=development war

或,简单

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

所以。在你成功完成上述步骤之后......是时候把你的谷物收集到一个罐子里......所以找到生成的战争地点在targets文件夹下你的created grails application folder

因此,在start manuallyautomatically启动TOmcat6/7。goto webapps服务器并复制您在上面生成的包后...首先停止{ {1}} ....干杯!