Jmeter中调用自己编写jar中的类出错
自己编写Java类打jar包,并将jar包放置到Jmeter/lib/ext/目录下,启动Jmeter,并在Jmeter中编写脚本调用jar包中的类,执行脚本出现以下问题:
错误日志:
2017/01/12 17:29:17 INFO - jmeter.engine.StandardJMeterEngine: Running the test!
2017/01/12 17:29:17 INFO - jmeter.samplers.SampleEvent: List of sample_variables: []
2017/01/12 17:29:17 INFO - jmeter.testelement.TestPlan: add D:\Tool\Jmeter\apache-jmeter-3.0\lib\ext\uaastool.jar to classpath
2017/01/12 17:29:17 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*)
2017/01/12 17:29:17 INFO - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : getChallenge
2017/01/12 17:29:17 INFO - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group getChallenge.
2017/01/12 17:29:17 INFO - jmeter.engine.StandardJMeterEngine: Thread will continue on error
2017/01/12 17:29:17 INFO - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false
2017/01/12 17:29:17 INFO - jmeter.threads.ThreadGroup: Started thread group number 1
2017/01/12 17:29:17 INFO - jmeter.engine.StandardJMeterEngine: All thread groups have been started
2017/01/12 17:29:17 INFO - jmeter.threads.JMeterThread: Thread started: getChallenge 1-1
2017/01/12 17:29:17 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` String challenge = vars.get("challenge"); String response = com.uaastool.UaasTo . . . '' : Typed variable declaration : Class: com.uaastool.UaasTool.UaasTool not found in namespace
2017/01/12 17:29:17 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: `` String challenge = vars.get("challenge"); String response = com.uaastool.UaasTo . . . '' : Typed variable declaration : Class: com.uaastool.UaasTool.UaasTool not found in namespace
2017/01/12 17:29:17 INFO - jmeter.threads.JMeterThread: Thread is done: getChallenge 1-1
2017/01/12 17:29:17 INFO - jmeter.threads.JMeterThread: Thread finished: getChallenge 1-1
2017/01/12 17:29:17 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test
2017/01/12 17:29:17 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*)
2017/01/12 17:30:09 INFO - jmeter.engine.StandardJMeterEngine: Running the test!
2017/01/12 17:30:09 INFO - jmeter.samplers.SampleEvent: List of sample_variables: []
2017/01/12 17:30:09 INFO - jmeter.testelement.TestPlan: add D:\Tool\Jmeter\apache-jmeter-3.0\lib\ext\uaastool.jar to classpath
2017/01/12 17:30:09 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*)
2017/01/12 17:30:09 INFO - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : getChallenge
2017/01/12 17:30:09 INFO - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group getChallenge.
2017/01/12 17:30:09 INFO - jmeter.engine.StandardJMeterEngine: Thread will continue on error
2017/01/12 17:30:09 INFO - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false
2017/01/12 17:30:09 INFO - jmeter.threads.ThreadGroup: Started thread group number 1
2017/01/12 17:30:09 INFO - jmeter.engine.StandardJMeterEngine: All thread groups have been started
2017/01/12 17:30:09 INFO - jmeter.threads.JMeterThread: Thread started: getChallenge 1-1
2017/01/12 17:30:09 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` String challenge = vars.get("challenge"); String response = com.uaastool.UaasTo . . . '' : Typed variable declaration : Class: com.uaastool.UaasTool.UaasTool not found in namespace
2017/01/12 17:30:09 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: `` String challenge = vars.get("challenge"); String response = com.uaastool.UaasTo . . . '' : Typed variable declaration : Class: com.uaastool.UaasTool.UaasTool not found in namespace
2017/01/12 17:30:09 INFO - jmeter.threads.JMeterThread: Thread is done: getChallenge 1-1
2017/01/12 17:30:09 INFO - jmeter.threads.JMeterThread: Thread finished: getChallenge 1-1
2017/01/12 17:30:09 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test
2017/01/12 17:30:09 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
出现以上错误的原因:
自己代码本身存在问题
Jmeter中引入包名及类名不正确
自己代码中引用的第三方jar包直接打入jar包
自己代码中引用的第三方jar包导入后,与Jmeter中已有jar包冲突。
1
2
3
4
解决方法:
首先确保自己的代码在开发工具中运行正常
其次检查Jmeter中是否进行正确的引入包名及类名
如脚本中引入正确,检查自己打的jar包
将自己的代码打包时不要将引用的其他第三方包打入jar包
将自己代码引用的第三方包放入Jmeter/lib/ext/目录下(需要检查导入jar包是否与Jmeter目前已有的jar包存冲突,需保证不存在jar包冲突)
将自己代码打的jar包放入Jmeter/lib/ext/目录下
重启Jmeter,再次运行脚本问题解决
1
2
3
4
5
6
7
这是我在使用Jmeter引入jar遇到过的问题,以及解决方案。欢迎交流,谢谢!
---------------------
作者:zijingqing
来源:CSDN
原文:https://blog.csdn.net/zijingqing/article/details/72723866
版权声明:本文为博主原创文章,转载请附上博文链接!