当前位置:网站首页>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
边栏推荐
- typing‘ has no attribute ‘_SpecialForm‘
- HOOPS Exchange助力混合计算流体动力学软件搭建3D格式导入读取功能 | 客户案例
- Redis Command Reference Manual - key
- 向左旋转k个字符串(细节)
- [oops framework] interface management
- 使用CMake编译OpenFoam求解器
- Jmeter之用户自定义变量和抽离公共变量
- Find the single dog (Li Kou 260)
- Redis命令参考手册 - Key
- Use localdate class to complete calendar design
猜你喜欢

Redis命令参考手册 - Key

DC-6 -- vulnhub range

找出单身狗(力扣260)
![[paper notes] - target attitude estimation Epro PNP 2022 CVPR](/img/96/9d3887c897950c4acaa7a01eb08b10.png)
[paper notes] - target attitude estimation Epro PNP 2022 CVPR

分布式事务和Seata的AT模式原理

你还在掐表算时间复杂度?

Azure Synapse Analytics 性能优化指南(1)——使用有序聚集列存储索引优化性能

Getting started with D3D calculation shaders

攻防世界web题-favorit_number

The way to understand JS: six common inheritance methods of JS
随机推荐
从另一个角度告诉你单元测试的意义
Getting started with D3D calculation shaders
Verilog语法基础HDL Bits训练 05
Use localdate class to complete calendar design
Distributed transaction and at mode principle of Seata
[directory] nodejs, NPM, yarn, bug
实战演练 | 查找在给定时间范围内购买超过 N 件商品的客户
How to use if in sql service
Leetcode notes 350. Intersection of two arrays II
GOM和GEE引擎黑屏不显示界面,装备地图怪物的解决方法
Tarjan finds the strongly connected component o (n+m), shrinking point
Hcip day 13
OAuth2和JWT
Research on the integrated data quality management system and technical framework under the scenario of data circulation and transaction
DC-6--vulnhub靶场
HNOI2012矿场搭建
Tensorflow 2 detailed explanation (TF ecosystem, installation, housekeeping, basic operation)
The difference between TCP and UDP
【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源
[array creation in numpy]