所以我在我的本地计算机上运行了STS的Grails应用程序,并且我尝试将其部署到CentOS / Tomcat服务器VM。我认为我正确安装了Groovy和Grails,或者至少我现在可以通过将它们添加到/ etc / bashrc中的路径来从控制台运行它们。但是,当我获取已编译的.war文件并将其放入Tomcat服务器的webapp目录并重新启动服务器时,它会抛出此错误:
Oct 17, 2011 4:33:21 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive CSTools-0.1.war
2011-10-17 16:33:29,558 [main] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:87)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:723)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:573)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:519)
Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8
at IbatisGrailsPlugin$_closure1_closure3.doCall(IbatisGrailsPlugin.groovy:48)
at grails.spring.BeanBuilder.invokeBeanDefiningMethod(BeanBuilder.java:679)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:550)
at IbatisGrailsPlugin$_closure1.doCall(IbatisGrailsPlugin.groovy:46)
at IbatisGrailsPlugin$_closure1.doCall(IbatisGrailsPlugin.groovy)
... 3 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.BytecodeInterface8
... 8 more
这里有什么建议吗?我似乎无法在网上找到可能有助于解决此错误的任何内容。据我所知,JVM是相同的(除了OS X / Linux版本),Grails和Groovy的版本也是如此。
答案 0 :(得分:7)
你不需要在Web服务器上安装Groovy或Grails,你只需要部署战争。战争中包含了常规罐子和所有Grails罐子。
这里的问题是,STS的编译类不知何故正在进入你的战争。看起来STS正在使用Groovy 1.8,但你使用的是1.3.x,它使用的Groovy 1.7没有BytecodeInterface8类。
STS类是否编译为WEB-INF / classes?那可能就是问题所在。我总是将它改为目标/ eclipseclasses,因此它们不在web-app下,在你建立战争时会被忽略。要更改它,请转到Project | Properties,Java Build Path部分,Source选项卡,然后更改“Default output folder”。
另一个选择是在一台不用于开发的干净机器上建立战争。