java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;

如果你出现类似如下错误

1. Install tomcat7 in my home directory and set up `CATALINA_HOME`
    environment variable in `.bashrc`
 2. Install oracle-java and setup JAVA_HOME in `.bashrc`
 3. Install Netbeans 7 and import the project in it.
 4. Since, the Netbeans came with `glassfish` as default server, I added
    a tomcat as the server with proper configuration.
 5. I try running the application (through Netbeans), and I receive the following error:

Jun 04, 2013 2:39:58 AM org.apache.catalina.core.AprLifecycleListener init
  2 INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/        lib:/usr/lib
  3 Jun 04, 2013 2:39:59 AM org.apache.coyote.AbstractProtocol init
  4 INFO: Initializing ProtocolHandler ["http-bio-8080"]
  5 Jun 04, 2013 2:39:59 AM org.apache.coyote.AbstractProtocol init
  6 INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  7 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.Catalina load
  8 INFO: Initialization processed in 1100 ms
  9 Jun 04, 2013 2:39:59 AM org.apache.catalina.core.StandardService startInternal
 10 INFO: Starting service Catalina
 11 Jun 04, 2013 2:39:59 AM org.apache.catalina.core.StandardEngine startInternal
 12 INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
 13 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.HostConfig deployDescriptor
 14 INFO: Deploying configuration descriptor /home/frrole/apache-tomcat-7.0.40/conf/Catalina/localhost/ws.xml
 15 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.HostConfig deployDescriptor
 16 WARNING: A docBase /home/frrole/apache-tomcat-7.0.40/webapps/projectfrrole/target/ws inside the host appBase has been specified, and will be ignored
 17 Jun 04, 2013 2:40:00 AM org.apache.catalina.core.ContainerBase addChildInternal
 18 SEVERE: ContainerBase.addChild: start:
 19 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ws]]
 20     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
 21     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
 22     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
 23     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
 24     at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
 25     at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
 26     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
 27     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
 28     at java.util.concurrent.FutureTask.run(FutureTask.java:166)
 29     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 30     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 31     at java.lang.Thread.run(Thread.java:722)
 32 Caused by: java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;
 33     at java.lang.Class.getDeclaredFields0(Native Method)
 34     at java.lang.Class.privateGetDeclaredFields(Class.java:2317)
 35     at java.lang.Class.getDeclaredFields(Class.java:1762)
 36     at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
 37     at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
 38     at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
 39     at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
 40     at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
 41     at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
 42     at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
 43     at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 44     at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
 45     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
 46     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 47     ... 11 more
 48 Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
 49     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)

那么原因暂时有两种:

1、你的项目没有依赖slf4j-log4j12.jar

2、如果你依赖了slf4j-log4j12.jar,那么请检测是否也依赖了slf4j-api.jar,他们会冲突,把slf4j-api.jar干掉吧

时间: 2024-10-12 07:40:35

java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;的相关文章

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger。。。

学习SpringBoot,启动主程序遇到如上异常,查找网上发现与slf4j-api-1.7.25.jar有关 到本地仓库 发现是jar包异常,删除文件夹,重新更新项目导入jar包,正常运行. 更新后jar包 原文地址:https://www.cnblogs.com/lhzh/p/10150501.html

Maven项目java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger报错

本文转载自:http://www.javaweb1024.com/info/894.jspx maven管理的项目,里面已经引入了log4j的包 maven引入如下: <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> <scope>compile</scope>

java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition

解决办法: 原先:<bean id="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 改成:<bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean

java.lang.NoClassDefFoundError: [Lorg/hibernate/eng

解决办法: 原先:<bean id="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 改成:<bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean

sparksql 提交到yarn出现 java.lang.NoClassDefFoundError: Lorg/apache/hadoop/hive/ql/plan/TableDesc

出现这个问题,是因为spark的excutor执行的时候,缺少hive的依赖包,添加依赖包的参数是: --conf "spark.executor.extraClassPath=/opt/cloudera/parcels/CDH-5.3.1-1.cdh5.3.1.p0.5/lib/hive/lib/*" 下面是是一个例子: spark-submit --class com.simple.spark.Test \    --master yarn-client \    --num-ex

日志异常:java.lang.NoClassDefFoundError: Could not initialize class org.slf4j.impl.StaticLoggerBinder

今天启动开发的项目,碰到了一个日志上的bug:java.lang.NoClassDefFoundError: Could not initialize class org.slf4j.impl.StaticLoggerBinder.刚看到一脸懵.于是到网上查了一下,也有遇到类似问题的.说是要加一些依赖,但是我试了不起作用.后来看到了一篇讲slf4j集成logback和log4j的文章,给我了我灵感,尝试了一下,解决了问题.文章的地址:https://www.jianshu.com/p/9a283

解决java.lang.NoClassDefFoundError: org/apache/log4j/Level

现象: java.lang.NoClassDefFoundError: org/apache/log4j/Level at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112

java.lang.AbstractMethodError: org.slf4j.impl.Log4

启动 Pivotal tc Server Developer Edition v3.0的时候报的错,下面得慢慢解决啊,有懂的给我回复一下哈,我要是解决了也会回复在文章下面的 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.AbstractMethodError:

Spring boot ---- java.lang.NoClassDefFoundError: javax/servlet/ServletContext

场景描述 项目中用到spring boot进行带页面的开发,从github上的simples中下载了对应的spring-boot-sample-web-jsp项目,经简单修改之后死活启动不起来,各种异常.spring-boot以简单容易上手为核心宗旨,可为什么在引入jar时就会出现这么多问题呢? 异常信息 异常一: 2016-06-17 11:04:14.216 ERROR 4684 --- [ main] o.s.boot.SpringApplication : Application sta