kafkameter noclassdeffounderror

bwitn5fc  于 2021-06-07  发布在  Kafka
关注(0)|答案(2)|浏览(463)

我希望通过jmeter插件管理器安装的jmeter扩展向kafka使用者发送动态生成的消息,从而对kafka进行负载测试。
我的Kafka是配置,设置和运行完美。我按照以下说明设置并运行kafka测试计划,但每次设置并运行时,日志中都会出现以下错误:

2017/03/23 10:35:48 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.assertions.BSFAssertion 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.extractor.BSFPostProcessor 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.modifiers.BSFPreProcessor 
2017/03/23 10:35:49 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2017/03/23 10:35:49 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2017/03/23 10:35:49 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2017/03/23 10:35:49 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2017/03/23 10:35:49 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser 
2017/03/23 10:35:49 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser 
2017/03/23 10:35:49 INFO  - jorphan.exec.KeyToolUtils: keytool found at 'keytool' 
2017/03/23 10:35:49 INFO  - jmeter.protocol.http.proxy.ProxyControl: HTTP(S) Test Script Recorder SSL Proxy will use keys that support embedded 3rd party resources in file /Users/jordan/Downloads/apache-jmeter-3.1/bin/proxyserver.jks 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.protocol.java.sampler.BSFSampler 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.protocol.mongodb.config.MongoSourceElement 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.protocol.mongodb.sampler.MongoScriptSampler 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.timers.BSFTimer 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.visualizers.BSFListener 
2017/03/23 10:35:49 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.visualizers.MonitorHealthVisualizer 
2017/03/23 10:35:49 INFO  - jmeter.samplers.SampleResult: Note: Sample TimeStamps are START times 
2017/03/23 10:35:49 INFO  - jmeter.samplers.SampleResult: sampleresult.default.encoding is set to ISO-8859-1 
2017/03/23 10:35:49 INFO  - jmeter.samplers.SampleResult: sampleresult.useNanoTime=true 
2017/03/23 10:35:49 INFO  - jmeter.samplers.SampleResult: sampleresult.nanoThreadSleep=5000 
2017/03/23 10:38:54 INFO  - jmeter.services.FileServer: Default base='/Users/jordan' 
2017/03/23 10:38:54 INFO  - jmeter.gui.action.Load: Loading file: /Users/jordan/Downloads/apache-jmeter-3.1/bin/test-plans/kafka-test.jmx 
2017/03/23 10:38:54 INFO  - jmeter.services.FileServer: Set new base='/Users/jordan/Downloads/apache-jmeter-3.1/bin/test-plans' 
2017/03/23 10:38:54 INFO  - jmeter.save.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2 
2017/03/23 10:38:54 INFO  - jmeter.save.SaveService: Using SaveService properties file encoding UTF-8 
2017/03/23 10:38:54 INFO  - jmeter.save.SaveService: Using SaveService properties version 3.1 
2017/03/23 10:38:54 INFO  - jmeter.save.SaveService: All converter versions present and correct 
2017/03/23 10:38:54 INFO  - jmeter.save.SaveService: Loading file: /Users/jordan/Downloads/apache-jmeter-3.1/bin/test-plans/kafka-test.jmx 
2017/03/23 10:38:54 INFO  - jmeter.services.FileServer: Set new base='/Users/jordan/Downloads/apache-jmeter-3.1/bin/test-plans' 
2017/03/23 10:39:04 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
2017/03/23 10:39:04 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2017/03/23 10:39:04 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2017/03/23 10:39:04 INFO  - jmeter.protocol.java.sampler.JavaSampler: Created class: co.signal.kafkameter.KafkaProducerSampler. Uses tearDownTest: true 
2017/03/23 10:39:04 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*) 
2017/03/23 10:39:05 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group 
2017/03/23 10:39:05 INFO  - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Thread Group. 
2017/03/23 10:39:05 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
2017/03/23 10:39:05 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false 
2017/03/23 10:39:05 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
2017/03/23 10:39:05 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2017/03/23 10:39:05 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 
2017/03/23 10:39:05 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at kafka.utils.Logging$class.logger(Logging.scala:24)
    at kafka.utils.VerifiableProperties.logger(VerifiableProperties.scala:23)
    at kafka.utils.Logging$class.info(Logging.scala:66)
    at kafka.utils.VerifiableProperties.info(VerifiableProperties.scala:23)
    at kafka.utils.VerifiableProperties.verify(VerifiableProperties.scala:180)
    at kafka.producer.ProducerConfig.<init>(ProducerConfig.scala:57)
    at co.signal.kafkameter.KafkaProducerSampler.setupTest(KafkaProducerSampler.java:90)
    at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(JavaSampler.java:193)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 12 more

2017/03/23 10:39:05 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-1 
2017/03/23 10:39:05 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2017/03/23 10:39:05 WARN  - jmeter.engine.StandardJMeterEngine: Error encountered during shutdown of org.apache.jmeter.protocol.java.sampler.JavaSampler@51cd3642 java.lang.NullPointerException
    at co.signal.kafkameter.KafkaProducerSampler.teardownTest(KafkaProducerSampler.java:96)
    at org.apache.jmeter.protocol.java.sampler.JavaSampler.testEnded(JavaSampler.java:292)
    at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:216)
    at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:437)
    at java.lang.Thread.run(Thread.java:745)

2017/03/23 10:39:05 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*)

所以,我得到的错误是它找不到 org/apache/log4j/logger ,但我不知道如何解决这个问题。我看了别人遇到的其他已知问题,看看它们是否与我的相似,但没有结果。我想我的测试计划可能写错了,但我找不到任何问题。关于我做错了什么有什么建议吗?

ru9i0ody

ru9i0ody1#

java.lang.classnotfoundexception此异常表示在类路径上找不到该类。这表明我们试图加载类定义,而类路径上不存在该类。
尝试添加log4jjar。
如果它是一个maven项目,您可以添加以下依赖项,随时更改为适当的版本。

<dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
   <version>1.2.15</version>
</dependency>

如果存在版本冲突,这也可能发生,因为log4jjar可能捆绑在另一个jar中,请尝试找出并排除log4jjar。

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.10</artifactId>
    <version>0.8.1.1</version>
    <exclusions>
        <exclusion>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>
xxslljrj

xxslljrj2#

我发现了问题所在。jmeter在它的 lib 文件夹,当下载并放入所述文件夹时,测试运行没有问题。

相关问题