gpt4 book ai didi

tomcat - Grails war 无法部署 java.lang.NoClassDefFoundError 和 SLF4J : Class path contains multiple SLF4J bindings

转载 作者:行者123 更新时间:2023-11-28 22:56:14 25 4
gpt4 key购买 nike

当我使用 grails run-app 时,我的应用程序工作正常,但是当尝试使用带有 run-war 的 war 文件运行时,我收到以下错误:

我已经在堆栈上尝试了这里提出的一些解决方案,但没有一个解决了问题。

跟踪中显示的包/类来 self 的一个域类:

nested exception is java.lang.NoClassDefFoundError: gneellaan/Ecf

gneellaan = packageEcf = domain class

|Running Grails application
Error |
SLF4J: Class path contains multiple SLF4J bindings.
Error |
SLF4J: Found binding in [jar:file:/C:/grails-2.4.2/dist/grails-plugin-log4j-2.4.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
Error |
SLF4J: Found binding in [jar:file:/C:/Grails/gneellaan/target/work/tomcat/webapps/gneellaan/WEB-INF/lib/grails-plugin-log4j-2.4.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
Error |
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Error |
SLF4J: Actual binding is of type [org.slf4j.impl.GrailsSlf4jLoggerFactory]
2014-10-23 14:28:08,255 [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: gneellaan/Ecf
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: gneellaan/Ecf
at java.lang.Class.forName(Class.java:340)
... 4 more
Caused by: java.lang.ClassNotFoundException: gneellaan.Ecf
... 5 more
2014-10-23 14:28:08,257 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: 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: gneellaan/Ecf
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: gneellaan/Ecf
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: gneellaan/Ecf
at java.lang.Class.forName(Class.java:340)
... 4 more
Caused by: java.lang.ClassNotFoundException: gneellaan.Ecf
... 5 more
2014-10-23 14:28:08,258 [localhost-startStop-1] ERROR context.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: gneellaan/Ecf
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: gneellaan/Ecf
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: gneellaan/Ecf
at java.lang.Class.forName(Class.java:340)
... 4 more
Caused by: java.lang.ClassNotFoundException: gneellaan.Ecf
... 5 more
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: gneellaan/Ecf
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: gneellaan/Ecf
at java.lang.Class.forName(Class.java:340)
... 4 more
Caused by: java.lang.ClassNotFoundException: gneellaan.Ecf
... 5 more
Error listenerStart
Context [/gneellaan] startup failed due to previous errors
The web application [/gneellaan] registered the JDBC driver [org.h2.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
The web application [/gneellaan] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
The web application [/gneellaan] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
|Server running. Browse to http://localhost:9091/gneellaan
|Server running. Browse to http://localhost:9091/gneellaan

最佳答案

正确 - 这是一个类路径问题,Slf4j 消息是可忽略的警告。 java.lang.ClassNotFoundExceptionjava.lang.NoClassDefFoundError 之间有很大的区别。 ClassNotFoundException 本身很简单 - 类路径中没有包含该类或资源的 jar 文件或目录。修复类路径,或向其中添加缺少的库,然后继续。

但是 NoClassDefFoundError(将导致 ClassNotFoundException)更难修复。它表示找到了命名的类,但是在加载它时,它没有满足依赖关系。这个在使用Grails、Maven、Gradle等集成依赖管理的时候应该是比较少见的,判断你的依赖的依赖是什么,并包含进去。但是,当我们将查找配置为不通过依赖关系图递归,或者排除一个或多个我们认为可以安全排除的 jar 时,就会发生这种情况。

我猜 gneellaan.Ecf 是您的类(class) - 在 Google 中恰好有 1 个结果,就是这个问题(从技术上讲,这是两个词,但我仍然称其为 Googlewhack ).如果它是第 3 方库,您可以使用像 http://mvnrepository.com/ 这样的网站确定依赖关系(例如 http://mvnrepository.com/artifact/io.hawt/hawtio-util/1.4.27 )。但是你有源头,所以不难找到原因。如果该类中发生了很多事情,请尝试注释掉你能注释掉的内容,确保所有内容仍然可以编译,但删除你能删除的内容。

关于tomcat - Grails war 无法部署 java.lang.NoClassDefFoundError 和 SLF4J : Class path contains multiple SLF4J bindings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26533021/

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