简体   繁体   中英

Error when deploying Grails app: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8

So I have a Grails app running in STS on my local machine, and I'm trying to deploy it to a CentOS/Tomcat server VM. I think I installed Groovy and Grails correctly, or at least I can run them from the console now, by adding them to the path in /etc/bashrc. However, when I take my compiled .war file, and put it in the Tomcat server's webapp directory and restart the server, it throws this error:

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

Any suggestions here? I can't seem to find anything online that might help with this error. So far as I can tell, the JVM is the same (aside from OS X/Linux versions), as are the versions of Grails and Groovy.

You do not need Groovy or Grails installed on the web server, you just need to deploy the war. The war contains the groovy-all jar and all Grails jars.

The problem here is that somehow the compiled classes from STS are making it into your war. It looks like STS is using Groovy 1.8 but you're using 1.3.x which uses Groovy 1.7 which doesn't have the BytecodeInterface8 class.

Are the STS classes compiled to WEB-INF/classes? That's probably the problem. I always change it to target/eclipseclasses so they're not under web-app and are ignored when you build the war. To change it go to Project|Properties, Java Build Path section, Source tab and change the "Default output folder".

Another option is to build the war on a clean machine that's not used for development.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM