Eclipse Tomcat java.lang.NoClassDefFoundError LogFactory

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24702778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 14:16:26  来源:igfitidea点击:

Eclipse Tomcat java.lang.NoClassDefFoundError LogFactory

javaeclipsetomcat

提问by railser

I've been struggling with this error for the past few days java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory Below is the console output.

过去几天我一直在努力解决这个错误 java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory 下面是控制台输出。

I am using the latest versions of Tomcat and Eclipse. EDIT - I tried uninstalling WAMP and installing the latest version of MYSQL community server to no avail; I'm still getting the same error.

我正在使用最新版本的 Tomcat 和 Eclipse。编辑 - 我尝试卸载 WAMP 并安装最新版本的 MYSQL 社区服务器,但无济于事;我仍然遇到同样的错误。

Note - I've consulted topics with the same issue yet none of the solutions suggested work for me. For example: java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

注意 - 我已经咨询了具有相同问题的主题,但没有一个解决方案对我有用。例如:java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

I tried adding tomcat-juli.jar as an external jar via the server classpath configuration in Eclipse, updating the system environment variable Classpath, copying the tomcat-juli.jar file into the lib folder of the JRE, and opening the file and confirming that the LogFactory class is indeed present.

我尝试通过 Eclipse 中的服务器类路径配置将 tomcat-juli.jar 添加为外部 jar,更新系统环境变量 Classpath,将 tomcat-juli.jar 文件复制到 JRE 的 lib 文件夹中,然后打开文件并确认LogFactory 类确实存在。

EDIT - Also, I am able to run the Tomcat server and view the default page in the browser by running startup.bat Any help is greatly appreciated.

编辑 - 另外,我能够运行 Tomcat 服务器并通过运行 startup.bat 在浏览器中查看默认页面 非常感谢任何帮助。

Jul 11, 2014 12:38:13 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.4.8.
Jul 11, 2014 12:38:13 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Jul 11, 2014 12:38:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server: ' did not find a matching property.
Jul 11, 2014 12:38:14 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014)
Jul 11, 2014 12:38:15 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Jul 11, 2014 12:38:15 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Jul 11, 2014 12:38:15 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1657 ms
Jul 11, 2014 12:38:15 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 11, 2014 12:38:15 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.9
Jul 11, 2014 12:38:15 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [127] milliseconds.
Jul 11, 2014 12:38:15 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ ]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:868)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    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: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ ]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
    at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.<clinit>(BasicDataSource.java:70)
    at org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:193)
    at org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance(BasicDataSourceFactory.java:182)
    at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:94)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:841)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
    at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1084)
    at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:663)
    at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:256)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5083)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
    at java.net.URLClassLoader.run(URLClassLoader.java:372)
    at java.net.URLClassLoader.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 22 more

Jul 11, 2014 12:38:15 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:752)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    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: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:868)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

Jul 11, 2014 12:38:15 PM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:752)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more

Jul 11, 2014 12:38:15 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-apr-8080"]
Jul 11, 2014 12:38:15 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-apr-8009"]
Jul 11, 2014 12:38:15 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jul 11, 2014 12:38:15 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-apr-8080"]
Jul 11, 2014 12:38:15 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-apr-8009"]
Jul 11, 2014 12:38:15 PM org.apache.catalina.deploy.NamingResourcesImpl cleanUp
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ ]] so no cleanup was performed for that container
javax.naming.NamingException: No naming context bound to this class loader
    at org.apache.naming.ContextBindings.getClassLoader(ContextBindings.java:258)
    at org.apache.catalina.deploy.NamingResourcesImpl.cleanUp(NamingResourcesImpl.java:992)
    at org.apache.catalina.deploy.NamingResourcesImpl.stopInternal(NamingResourcesImpl.java:975)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5415)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:272)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:840)
    at org.apache.catalina.core.ContainerBase.destroyInternal(ContainerBase.java:1013)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:840)
    at org.apache.catalina.core.ContainerBase.destroyInternal(ContainerBase.java:1013)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:603)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:842)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

采纳答案by Gladwin Burboz

  • Make sure your tomcat launch configuration has correct juli jar in classpath.
  • 确保您的 tomcat 启动配置在类路径中具有正确的 juli jar。

Tomcat launch configuration

Tomcat启动配置

  • Also where is your DBCP jars located? Try putting juli jar in same location
  • 另外你的 DBCP jars 在哪里?尝试将 juli jar 放在同一位置

JDK 1.8 that I have has following JARs in "jre\lib\ext". Move all other jars to tomcat endorsed as specified.

我在“jre\lib\ext”中有以下 JAR 的 JDK 1.8。将所有其他 jars 移动到指定的 tomcat。

access-bridge-64.jar
cldrdata.jar
dnsns.jar
jaccess.jar
jfxrt.jar
localedata.jar
meta-index
nashorn.jar
sunec.jar
sunjce_provider.jar
sunmscapi.jar
sunpkcs11.jar
zipfs.jar

回答by Shailendra

Here is what should definitely help you to find the cause. Append following to your tomcat jvm startup parameter

这绝对可以帮助您找到原因。将以下内容附加到您的 tomcat jvm 启动参数

-verbose:class

If you are running standalone Tomcat (by running startup.bat) you can put following lines in the catalina.bat

如果您正在运行独立的 Tomcat(通过运行startup.bat),您可以在catalina.bat

set JAVA_OPTS=%JAVA_OPTS% -verbose:class

What this does is print on the console / log - the class and the jar file location from which it is loaded beginning with the java bootstrap till the server bootstrap and your application classes. In short all the required classes for successfully running your application. The information is verbose but very useful in pinpointing the exact jar from the which the classes are picked or even if the jar is not being picked. It would be very helpful if you output the information to a file and then do a text search with a text editor.

它的作用是在控制台/日志上打印 - 从 java 引导程序开始加载它的类和 jar 文件位置,直到服务器引导程序和您的应用程序类。简而言之,成功运行应用程序所需的所有类。这些信息很冗长,但对于确定从中挑选类的确切 jar 或即使未挑选 jar 也非常有用。如果您将信息输出到文件,然后使用文本编辑器进行文本搜索,这将非常有用。

On my Tomcat installation, it shows information like this

在我的 Tomcat 安装中,它显示了这样的信息

[Loaded java.lang.Void from C:\Program Files\Java\jdk1.7.0_51\jre\lib\rt.jar]
[Loaded org.apache.juli.logging.LogFactory from file:/D:/apache-tomcat-7.0.50/bin/tomcat-juli.jar]
[Loaded org.apache.juli.logging.Log from file:/D:/apache-tomcat-7.0.50/bin/tomcat-juli.jar]
[Loaded org.apache.juli.logging.DirectJDKLog from file:/D:/apache-tomcat-7.0.50/bin/tomcat-juli.jar]
[Loaded java.util.logging.Logger from C:\Program Files\Java\jdk1.7.0_51\jre\lib\rt.jar]
[Loaded java.util.logging.Handler from C:\Program Files\Java\jdk1.7.0_51\jre\lib\rt.jar]

You can see the org.apache.juli.logging.LogFactorybeing loaded from file:/D:/apache-tomcat-7.0.50/bin/tomcat-juli.jar

你可以看到org.apache.juli.logging.LogFactory正在加载file:/D:/apache-tomcat-7.0.50/bin/tomcat-juli.jar

回答by Gladwin Burboz

Although previous answer posted solves issue but it is a dirty solution.

虽然之前发布的答案解决了问题,但它是一个肮脏的解决方案。

Configure your DBCP jars correctly as specified in following links. Also move out any other jars to $CATALINA_HOME/endorsed dir

按照以下链接中的说明正确配置 DBCP jar。还将任何其他 jars 移出到 $CATALINA_HOME/endorsed 目录

JNDI Datasource HOW-TO

JNDI 数据源操作指南

The Tomcat JDBC Connection Pool

Tomcat JDBC 连接池

回答by abhati

Here is the checklist :-

这是清单:-

  1. Same copy of tomcat-juli.jar is present at JRE\lib,TOMCAT\lib and launch configuration of eclipse,to make sure one used contains LogFactory.
  2. You are using Eclipse's in built in server configuration tool instead of a plugin.
  3. Could be a bugin tomcat's version you are using.
  1. 相同的 tomcat-juli.jar 副本存在于 JRE\lib、TOMCAT\lib 和 eclipse 的启动配置中,以确保使用的一个包含 LogFactory。
  2. 您正在使用 Eclipse 的内置服务器配置工具而不是插件。
  3. 可能是您使用的 tomcat 版本中的错误