jmeter之Java request报错:java.lang.NoClassDefFoundError: redis/clients/jedis/Jedis
今天在学习Jmeter的java request,请求内容是连接redis并获取其中的一个字段值。结果在运行时报如下错误:
2018/05/24 13:08:20 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.NoClassDefFoundError: redis/clients/jedis/Jedis
at cn.testfan.redis.RedisJavaTest.setupTest(RedisJavaTest.java:36)
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(Unknown Source)
Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.Jedis
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
报错原因:jmeter中缺少相应jar包。
解决方法:在网上下载jedis-2.9.0.jar后将其放到jmeter的lib目录下,重启jmeter,运行成功。