Log4j2 - java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor

问题

项目使用了log4j2,由于使用了全局异步打印日志的方式,还需要引入disruptor的依赖,最后使用的log4j2和disruptor的版本依赖如下:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.11.1</version>
</dependency>
<!-- log4j2 AsyncLogger need disruptor-->
<dependency>
    <groupId>com.lmax</groupId>
    <artifactId>disruptor</artifactId>
    <version>3.2.0</version>
</dependency>

在项目最开始的地方(第一次使用到log4j2的logger之前),通过代码来启用全局异步打印日志:

// use asyncLogger for log4j2 framework
System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");

然而在启动项目后报错如下:

java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor.<init>(Lcom/lmax/disruptor/EventFactory;ILjava/util/concurrent/ThreadFactory;Lcom/lmax/disruptor/dsl/ProducerType;Lcom/lmax/disruptor/WaitStrategy;)V
        at org.apache.logging.log4j.core.async.AsyncLoggerDisruptor.start(AsyncLoggerDisruptor.java:97)
        at org.apache.logging.log4j.core.async.AsyncLoggerContext.start(AsyncLoggerContext.java:75)
    at .......

解决方法

该问题是因为Disruptor的版本较低导致,将版本改用较新版本的即可:

<dependency>
    <groupId>com.lmax</groupId>
    <artifactId>disruptor</artifactId>
    <version>3.4.2</version>
</dependency>

原文地址:https://www.cnblogs.com/yulinlewis/p/10211563.html

时间: 2024-11-05 14:38:45

Log4j2 - java.lang.NoSuchMethodError: com.lmax.disruptor.dsl.Disruptor的相关文章

java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;问题

在springsecurity学习中,在加入spring有关的jar包后,出现java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment报错 出错原因:jar包版本有冲突 解决方法:换不同版本的jar包就可以解决问题了

Exception in thread &quot;main&quot; java.lang.NoSuchMethodError: org.testng.TestNG.configure(Lorg/testng/CommandLineArgs;)V

TestNG运行时报以下错误: Exception in thread "main" java.lang.NoSuchMethodError: org.testng.TestNG.configure(Lorg/testng/CommandLineArgs;)V at org.testng.remote.AbstractRemoteTestNG.configure(AbstractRemoteTestNG.java:77) at org.testng.remote.RemoteTestN

Hibernate常见错误:java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibe

hibernate4 与 spring3有点冲突 http://blog.csdn.net/gyflyx/article/details/7632645 整合NoSuchMethodError错误 and 升级Spring3.1RC2 和Hibernate4.0.0CR7遇到的一些问题及解决 2012-02-20 10:33:28|  分类: 编程_SSH |字号 订阅 我使用的是hibernate4和spring3,然后报的错误是 java.lang.NoSuchMethodError: or

java.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.getManager(Ljava/lang/Class;)Lorg/apache/tomcat/util/res/StringManager

java.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.getManager(Ljava/lang/Class;)Lorg/apache/tomcat/util/res/StringManager 问题: 使用Springboot打包为war部署于Tomcat7中报错 java.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.get

java.lang.NoSuchMethodError

1.错误描述 03-Oct-2014 00:17:23.095 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 03-Oct-2014 00:17:23.168 INFO [localhost-startStop-1] org.apache.catalina.cor

java.lang.NoSuchMethodError: ognl.SimpleNode.isEvalChain(Lognl/OgnlContext;)Z解决方法

运行JavaEE项目时出现如下错误: java.lang.NoSuchMethodError: ognl.SimpleNode.isEvalChain(Lognl/OgnlContext;)Z at com.opensymphony.xwork2.ognl.OgnlUtil.isEvalExpression(OgnlUtil.java:245) at com.opensymphony.xwork2.ognl.OgnlUtil.checkEnableEvalExpression(OgnlUtil.

java.lang.NoSuchMethodError: org.springframework.dao.IncorrectResultSizeDataAccessException

spring data jpa  运用,在dao类中写自己新增的方法,使用@query写hql语句,出现以下异常: Caused by: java.lang.NoSuchMethodError: org.springframework.dao.IncorrectResultSizeDataAccessException.<init>(Ljava/lang/String;ILjava/lang/Throwable;)V at org.springframework.orm.jpa.EntityM

Spring Boot常见问题(二)Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;

问题描述:通过Spring Boot官方提供的方式,写出如下HelloWorld代码. @Controller @EnableAutoConfiguration public class HelloWorld { @RequestMapping("/wu") @ResponseBody String home() { return "Hello World!"; } public static void main(String[] args) throws Exce

Caused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode

进行 spring mvc jpa整合时.Junit方法测试时. 异常: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested excep