gpt4 book ai didi

tomcat - 将 Grails 2.5 应用程序部署到 Tomcat8

转载 作者:行者123 更新时间:2023-11-28 23:30:06 30 4
gpt4 key购买 nike

我正在尝试将 Grails v2.5.0 应用程序部署到 Tomcat 8.0.22 并收到以下错误:

2015-07-25 13:11:09,714 ERROR [GrailsContextLoaderListener] - Error initializing Grails: 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:
net/sf/cglib/proxy/UndeclaredThrowableException
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:
net/sf/cglib/proxy/UndeclaredThrowableException at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.lang.NoClassDefFoundError:
net/sf/cglib/proxy/UndeclaredThrowableException at
java.lang.Class.forName(Class.java:348) ... 5 more Caused by:
java.lang.ClassNotFoundException:
net.sf.cglib.proxy.UndeclaredThrowableException ... 6 more
25-Jul-2015 13:11:09.715 SEVERE [wwww startStop-1]
org.apache.catalina.core.StandardContext.listenerStart 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 'grailsApplication' defined in ServletContext
resource [/WEB-INF/applicationContext.xml]: Invocation of init method
failed; nested exception is java.lang.NoClassDefFoundError:
net/sf/cglib/proxy/UndeclaredThrowableException at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.lang.NoClassDefFoundError:
net/sf/cglib/proxy/UndeclaredThrowableException at
java.lang.Class.forName(Class.java:348) ... 5 more Caused by:
java.lang.ClassNotFoundException:
net.sf.cglib.proxy.UndeclaredThrowableException ... 6 more

net/sf/cglib 已添加到 tomcat8 共享库文件夹中,但它只会导致 net/sf/cglib/proxy/UndeclaredThrowableException在开发模式下从未遇到过。

最佳答案

这可能只有两个原因。第一个是,您的 WAR 包含所需库 cglib 的两个版本的 jar,第二个是您的 WAR 根本不包含该库。

http://mvnrepository.com/artifact/cglib/cglib/3.1

由于上述任何原因,您将始终得到 NoClassDefFoundError。但是,您可以轻松解决此问题。当您将 WAR 文件部署到 Tomcat 时,WAR 文件被提取,然后 ls 进入展开的 WAR 的 lib 文件夹:ls -al $CATALINA_HOME/webapps/ROOT/WEB-INF/lib/ 并查找名为 cglib-*.jar 的 jar 文件。

现在,有两种可能性,正如我上面所描述的,要么没有名称为 cglib 的 jar 文件可用,要么有两个名称为 cglib 的 jar 文件两个不同的版本。

第一种情况的解决方案,您可以在 BuildConfig.groovy 中添加依赖项,例如:compile 'cglib:cglib:2.2.2'

对于第二种情况,您可以使用 grails dependency-report 来查看该库是如何被复制的,并且可以排除

注意:对于第二步,如果您想立即修复,只需从我指定的位置删除其中一个 jar 并重新启动 Tomcat。

关于tomcat - 将 Grails 2.5 应用程序部署到 Tomcat8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31626912/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com