当前位置:网站首页>The bumpy road of referencing jar package json-path.jar in jmeter/idea
The bumpy road of referencing jar package json-path.jar in jmeter/idea
2022-07-26 00:43:00 【The test is super standard】
Talking about JMeter Before the error introduced in , Let's talk first. IDEA Introduction in json-path-xxx.jar Wrong question
Pictured , Introduce in the project json-path package .

FileInputStream fis = new FileInputStream(file);
Map<String, Object> loaded = (Map<String, Object>) yaml.load(fis);
String header_str = new JSONObject(loaded).toString();
String data = JsonPath.read(header_str,"$.sit.adminun");Prompt at execution :
Exception in thread "main" java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI
at com.jayway.jsonpath.internal.DefaultsImpl.<init>(DefaultsImpl.java:17)
at com.jayway.jsonpath.internal.DefaultsImpl.<clinit>(DefaultsImpl.java:15)
at com.jayway.jsonpath.Configuration.getEffectiveDefaults(Configuration.java:43)
at com.jayway.jsonpath.Configuration.defaultConfiguration(Configuration.java:168)
at com.jayway.jsonpath.internal.ParseContextImpl.<init>(ParseContextImpl.java:21)
at com.jayway.jsonpath.JsonPath.read(JsonPath.java:550)
at com.functions.ReadYaml.main(ReadYaml.java:33)
Caused by: java.lang.ClassNotFoundException: net.minidev.json.writer.JsonReaderI
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
reason , As the Internet says , Lack of package dependencies !!!
Because we put the package into the project statically , I can't see json-path It depends on the package , But when through Maven When the download , I found that I downloaded several other packages !!! Run again and there will be no problem ~~(PS: It is also possible to statically introduce all dependent packages )
Preliminary conclusion , It seems to simply quote json-path Will report a mistake , You need to add dependent packages . Next , Let's talk about it JMeter Simply by introducing json-path The problem of package error reporting .
JMeter Introduce error report
JMeter Problem description in :
1、 stay jmeter Use in beanshell Script time , Use json-path-xxxxx.jar analysis json An error will be reported when the data is :Error in method invocation: Static method read( java.lang.String, java.lang.String ) not found in class'com.jayway.jsonpath.JsonPath.
import com.jayway.jsonpath.JsonPath;
String s = prev.getResponseDataAsString();
String res = JsonPath.read(s,"$..idcard").toString();
log.info("-------------"+res);Specific error report :
2022-07-25 21:14:58,749 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import com.jayway.jsonpath.JsonPath; String s = prev.getResponseDataAsString(); . . . '' : Typed variable declaration : Error in method invocation: Static method read( java.lang.String, java.lang.String ) not found in class'com.jayway.jsonpath.JsonPath'
2022-07-25 21:14:58,749 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import com.jayway.jsonpath.JsonPath; String s = prev.getResponseDataAsString(); . . . '' : Typed variable declaration : Error in method invocation: Static method read( java.lang.String, java.lang.String ) not found in class'com.jayway.jsonpath.JsonPath'
Solution :
programme 1: since idea There is a simple verification in that there is a lack of dependent packages , Then let's add a dependency package to him , And found that , These dependencies are packaged in lib There are... In the directory !!!! It still doesn't work !!
programme 2: Write code , Code thinking : class JsonUtil The method in ParaseJson encapsulation read Method , The first parameter is json character string , The second parameter is jsonpath, Export code as jar package , Package put path \apache-jmeter-5.0\lib\ext .
import com.jayway.jsonpath.JsonPath;
public class JsonUtil {
public String ParaseJson(String str,String paras){
String res = JsonPath.read(str,paras).toString();
return res;
}
}The source of this solution :jmeter Let's work it out :beanshell Use jsonpath analysis json Report errors
Author Baidu online disk jmeterUtil.jar, Extraction code :o0fr
Last :
Speak true ,JMeter Zhongzhong still doesn't understand the root cause of this problem ... A clear boss asked for advice ~
Reference resources :jmeter I quote jar package jsonpath The rough road : - Let's have a look
边栏推荐
- HOOPS Exchange助力混合计算流体动力学软件搭建3D格式导入读取功能 | 客户案例
- 【oops-framework】网络模块WebSocket
- YOLOV2 YOLO9000
- 2022/7/25 exam summary
- In order to grasp the redis data structure, I drew 40 pictures (full version)
- Shardingsphere data slicing
- Solve the problem that when the background image is set to be 100% full, when the horizontal scroll bar appears in the zoom browser, the part of the background image beyond the scroll bar is not full
- GOM和GEE引擎黑屏不显示界面,装备地图怪物的解决方法
- [zero based BLDC series] brushless DC motor control principle based on the zero crossing detection method of back EMF
- [IJCAI 2022] parameter efficient large model sparse training method, which greatly reduces the resources required for sparse training
猜你喜欢

Modeling and simulation analysis of online medical crowdfunding communication based on SEIR model

Hcip day 11

Hcip - republish

DC-6 -- vulnhub range

BGP 综合实验

Research on text classification of e-commerce comments based on mffmb

Hcip day 13

SQL server failed to send mail, prompting that the recipient must be specified

Comparing the seven distributed transaction schemes, I prefer Alibaba's open source Seata (principle + Practice)

What is the difference between request forwarding and request redirection?
随机推荐
Curd used by hyperf
SereTOD2022 Track1代码剖析-面向半监督和强化学习的任务型对话系统挑战赛
Data driven DDT for automated testing
分布式事务和Seata的AT模式原理
力扣记录:剑指offer(2)——JZ13-22
Trial division -- power of 3
[plaything determination scratch children programming] ride a small motorcycle (dynamic background + camera control operation)
ASP.NET Core配置
sql(基础二)
本地电脑架设传奇怎么开外网叫朋友一起玩?
Azure synapse analytics Performance Optimization Guide (1) -- optimize performance using ordered aggregate column storage indexes
Analysis and practice of parameter parser handlermethodargumentresolver
攻防世界web题-favorit_number
Nodejs starts mqtt service with an error schemaerror: expected 'schema' to be an object or Boolean problem solving
8 tips to adjust database performance optimization, yyds
参数解析器HandlerMethodArgumentResolver分析与实战
Applet page generation link sent by SMS
【零基础玩转BLDC系列】基于反电动势过零检测法的无刷直流电机控制原理
Comparing the seven distributed transaction schemes, I prefer Alibaba's open source Seata (principle + Practice)
YOLOV3