Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Groovy Grails工具套件NoClassDefFoundError在WAR部署中_Java_Tomcat_Grails_Groovy - Fatal编程技术网

Java Groovy Grails工具套件NoClassDefFoundError在WAR部署中

Java Groovy Grails工具套件NoClassDefFoundError在WAR部署中,java,tomcat,grails,groovy,Java,Tomcat,Grails,Groovy,使用:GG版本2.2.4;Groovy/Grails工具套件版本:3.3.0.0 这里有一个问题:如何将特定的Grails JAR放入使用GGT构建的战争中 作为附带问题,为什么战争没有把那个罐子包装进去?为什么grails run应用程序工作得很好,但在开发或生产中部署战争失败了 背景如下: 当我在Windows 7开发计算机上本地运行grails run war时,它会出现以下故障: 2013-10-16 11:36:05,371 [localhost-startStop-1] ERROR

使用:GG版本2.2.4;Groovy/Grails工具套件版本:3.3.0.0

这里有一个问题:如何将特定的Grails JAR放入使用GGT构建的战争中

作为附带问题,为什么战争没有把那个罐子包装进去?为什么grails run应用程序工作得很好,但在开发或生产中部署战争失败了

背景如下:

当我在Windows 7开发计算机上本地运行grails run war时,它会出现以下故障:

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**
当我运行grails war,然后将生产war部署到我的服务器上的Tomcat 6时,在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)
我可以在WAR内部进行探索,发现WEB-INF/lib/不包含上述两个类所在的JAR-grails-plugin-testing-2.2.4.JAR

我试着把

grails.war.dependencies = [
    "grails-plugin-testing-2.2.4.jar"
    ]
进入config.groovy,这不起作用。战争仍然没有包含那个罐子,我也犯了同样的错误

因此,我只是将grails-plugin-testing-2.2.4.jar放入服务器上的WEB-INF/lib文件夹中,重新部署并验证上述错误是否消失,但现在服务器上出现了另一个错误:

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
我将调查第二个错误,并在另一个问题中询问它,并在这里引用它。[更新:如果我也将grails-test-2.2.4.jar放入服务器上的WEB-INF/lib中,这个错误就会消失。然后,WAR部署并成功运行。]

为了让这个问题/答案只针对一个主题,我如何让这两个罐子投入战争

但是,当然,也许有一个解决方案可以解决他所面临的两个问题——不太可能,但值得一提!例如,我不知道为什么使用grails-plugin-testing-2.2.4.jar。也许有一个设置我需要改变,让它消失


谢谢

好的-解决了-足够让它工作了

[仍然困惑于GG为什么没有自己捡起那些罐子。]

为了找出哪些JAR文件包含在WAR部署过程中报告丢失的类,我只是在包含grails JAR的dist文件夹中进行了一次搜索,其中安装了Groovy/grails v2.2.4 C:\grails-2.2.4\dist。我使用7zip浏览JAR。因为这两个类都有test这个词,所以我首先在名称为test的JARS中查找,很容易找到它们。这就是我在上面的问题中列出的包含这些类的两个JAR文件的计算方法

将它们放在服务器上的WEB-INF/lib文件夹中,然后成功启动/部署项目,这证实了让它们参与战争可以解决问题

为了让他们参与到项目中,从而在战争开始时,我做了这个

1) run “grails clean” on the project in question
2) close the project (and all others)
3) exit g&g tool suite
4) drag the jar file to your “PROJECTNAME/lib” directory for your project using Windows Explorer.
5) start g&g tool suite
6) open the project
7) right-click on the Project Name and choose Groovy Tools -> Refresh Dependencies

现在,也许你不必为了让刷新依赖项起作用而跳过所有这些障碍,但我就是这么做的。如果我只做7,而不先做其他的事情,它在这个版本的GGTS上就不起作用。现在,WAR将在服务器上正确生成和部署。

BootStrap.groovy中有什么内容吗?你的战争似乎有一些东西取决于混战,但不应该。是的,塞吉奥。我确实在BootStrap.groovy中构建了测试数据,并导入了grails.buildtestdata.mixin.build。我正在使用构建测试数据2.0.5插件。不过还是很好奇。为什么它能在开发中与run app一起工作,但却像本地开发和服务器上的生产一样失败了。但是,当我将jar作为依赖项添加到PROJECTNAME/lib文件夹中时,它确实解决了我的问题。所以,我正在继续。然而,如果我能/应该做些别的事情来移除那些罐子并让它工作的话,我很乐意测试一下。