问题描述
近期使用Jmeter时发现了一个非常奇怪的问题,就是Jmeter是可以正常使用运行脚本,但是在Log viewer中确没有任何日志,如下图:
问题排查过程
真是百思不得其解啊,在网上各种获取资料,大多数都是说跟Jmeter的log日志配置有关系,按照指引 ,真是一顿操作猛如虎,仔细一看原地杵啊!!! 没有任何效果!!! 然后重新解压了同版本(5.4.1)的jmeter(保证jmeter 是干净的),没有出现任何问题,排除了jmeter版本的bug。
这时我又重新启动了我出现问题的jmeter,偶然发现控制台报错,信息如下:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/apache-jmeter-5.4.1/lib/activemq-all-5.16.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/apache-jmeter-5.4.1/lib/log4j-slf4j-impl-2.13.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Reload4jLoggerFactory]
INFO | Setting Locale to en_EN
INFO | Loading user properties from: user.properties
INFO | Loading system properties from: system.properties
INFO | Copyright (c) 1998-2021 The Apache Software Foundation
INFO | Version 5.4.1
INFO | java.version=1.8.0_151
INFO | java.vm.name=Java HotSpot(TM) 64-Bit Server VM
INFO | os.name=Windows 10
INFO | os.arch=amd64
INFO | os.version=10.0
INFO | file.encoding=GBK
INFO | java.awt.headless=null
INFO | Max memory =2147483648
INFO | Available Processors =4
INFO | Default Locale=English (EN)
INFO | JMeter Locale=English (EN)
INFO | JMeterHome=C:\apache-jmeter-5.4.1
INFO | user.dir =C:\apache-jmeter-5.4.1\bin
INFO | PWD =C:\apache-jmeter-5.4.1\bin
INFO | IP: 10.32.166.9 Name: PC-20230210MTLI FullName: host.docker.internal
INFO | search_paths=../lib;../lib/ext;../lib/ext/ice_lib;../lib/ext/js_video_lib;
INFO | Adding to classpath and loader: ../lib
INFO | Adding to classpath and loader: ../lib/ext
INFO | Adding to classpath and loader: ../lib/ext/ice_lib
INFO | Adding to classpath and loader: ../lib/ext/js_video_lib
================================================================================
Don't use GUI mode for load testing !, only for Test creation and Test debugging.
For load testing, use CLI Mode (was NON GUI):
jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
& increase Java Heap to meet your test requirements:
Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the jmeter batch file
Check : https://jmeter.apache.org/usermanual/best-practices.html
================================================================================
INFO | Setting LAF to: laf:com.sun.java.swing.plaf.windows.WindowsLookAndFeel
INFO | Loaded icon properties from org/apache/jmeter/images/icon.properties
WARN | Found JAR conflict: ..\lib\accessors-smart-1.2.jar and C:\apache-jmeter-5.4.1\lib\accessors-smart-1.2.jar
WARN | Found JAR conflict: ..\lib\activemq-all-5.16.5.jar and C:\apache-jmeter-5.4.1\lib\activemq-all-5.16.5.jar
WARN | Found JAR conflict: ..\lib\apiguardian-api-1.1.0.jar and C:\apache-jmeter-5.4.1\lib\apiguardian-api-1.1.0.jar
WARN | Found JAR conflict: ..\lib\asm-9.0.jar and C:\apache-jmeter-5.4.1\lib\asm-9.0.jar
WARN | Found JAR conflict: ..\lib\bsf-2.4.0.jar and C:\apache-jmeter-5.4.1\lib\bsf-2.4.0.jar
WARN | Found JAR conflict: ..\lib\bsh-2.0b6.jar and C:\apache-jmeter-5.4.1\lib\bsh-2.0b6.jar
WARN | Found JAR conflict: ..\lib\bshclient.jar and C:\apache-jmeter-5.4.1\lib\bshclient.jar
WARN | Found JAR conflict: ..\lib\caffeine-2.8.8.jar and C:\apache-jmeter-5.4.1\lib\caffeine-2.8.8.jar
WARN | Found JAR conflict: ..\lib\checker-qual-3.8.0.jar and C:\apache-jmeter-5.4.1\lib\checker-qual-3.8.0.jar
WARN | Found JAR conflict: ..\lib\commons-codec-1.15.jar and C:\apache-jmeter-5.4.1\lib\commons-codec-1.15.jar
WARN | Found JAR conflict: ..\lib\commons-collections-3.2.2.jar and C:\apache-jmeter-5.4.1\lib\commons-collections-3.2.2.jar
WARN | Found JAR conflict: ..\lib\commons-collections4-4.4.jar and C:\apache-jmeter-5.4.1\lib\commons-collections4-4.4.jar
WARN | Found JAR conflict: ..\lib\commons-dbcp2-2.8.0.jar and C:\apache-jmeter-5.4.1\lib\commons-dbcp2-2.8.0.jar
WARN | Found JAR conflict: ..\lib\commons-io-2.8.0.jar and C:\apache-jmeter-5.4.1\lib\commons-io-2.8.0.jar
WARN | Found JAR conflict: ..\lib\commons-jexl-2.1.1.jar and C:\apache-jmeter-5.4.1\lib\commons-jexl-2.1.1.jar
解决办法
此时问题真像大白,是引入了第三方jar包,产生了版本冲突(该问题是我之前压测mq引入的jar包,当时压测是可以正常执行的,所以就一直没太注意这个问题。。。)
所以大家在使用Jmeter引入第三方jar包进行测试时,一旦发现了一些莫名其妙的问题,可以排查一下是不是自己引入的jar包造成的版本冲突!
我的每一篇文章都希望帮助读者解决实际工作中遇到的问题!如果文章帮到了您,劳烦点赞、收藏、转发!您的鼓励是我不断更新文章最大的动力!