报错内容
0,0,,Non HTTP response code: java.net.MalformedURLException,Non HTTP response message: Illegal character found in host: '/',test_configkeeper 1-1,text,false,Expected to find an object with property ['configSourceId'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.,784,0,1,1,null,0,0,0
报错内容也是很长,根本就看不懂啥意思,但是基本意思就是http请求没有正常发送,host不对,因为博主使用了HTTP Request Defaults,然后在HTTP Request Defaults中的server Name or ip 设置的内容是:
所以就把后面这个把他挪走就好了,仅剩下IP就好了,就解决了这个问题
报错2
Java.sql.sqlexception connot create poolableconnectionfactory
解决办法
MySQL.server 版本应该是mysql-connector-java-5.1.12-bin.jar,我一开始用的是mysql-connector-java-8.0.11.jar,版本应该是太高了。我的jre版本是1.8
报错3
ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of
代码如下:
解决办法
因为所有jmeter的内部变量都是String类型的,要做类型的强转,不能用int直接接收
// 关键代码
int after_number = Integer.parseInt(a);
报错4
在jmeter中的beanshell脚本内容中,是不支持泛型类型的填写,只能写成非泛型才能执行成功,修改后如下;如果想使用只能通过Java实现,然后打成jar包,之后在线程组导入jar包
List arr = new ArrayList();
报错5
报错内容
{“errorCode”:“InternalError”,“errorMessage”:“Could not read JSON: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 26 column 51 path $.forwarderConfigs[0].paramConfig.requestBodyPatterns.; nested exception is com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 26 column 51 path $.forwarderConfigs[0].paramConfig.requestBodyPatterns.”}
原因是在请求的boby中有一串正则匹配的字符串,而这一串字符串在postman里面是可以请求成功的,但是jmeter里面不可以,因此定位问题用了很久:
"paramConfig": {
"pathPatternMatch": true,
"requestBodyPatterns": {
"echoToken": "\"echoToken\"[\\s]*:[\\s]*\"(.+?)\"",
"timeStamp": "\"timeStamp\"[\\s]*:[\\s]*\"(.+?)\"",
"version": "\"version\"[\\s]*:[\\s]*\"(.+?)\"",
"hotelSystemHotelId": "\"hotelId\"[\\s]*:[\\s]*\"(.+?)\""
}
}
解决办法:
就是在这个地方由 [\\s]换成 [\\\s]
"paramConfig": {
"pathPatternMatch": true,
"requestBodyPatterns": {
"echoToken": "\"echoToken\"[\\\s]*:[\\\s]*\"(.+?)\"",
"hotelSystemHotelId":"\"hotelId\"[\\\s]*:[\\\s]*\"(.+?)\"",
"timeStamp": "\"timeStamp\"[\\\s]*:[\\\s]*\"(.+?)\"",
"version": "\"version\"[\\\s]*:[\\\s]*\"(.+?)\""
}
}
报错6
报错内容
Error invoking bsh method: eval Sourced file: inline evaluation of:
import java.text.SimpleDateFormat; import org.apache.jmeter.protocol.http.sample . . . '' Token Parsing Error: Lexical error at line 11, column 77. Encountered: "\n" (10), after : "\"{\\\"forwarderKey\\\": \\\"zoeOPERADERBYTEST9188\\\",\\\"type\\\": \\\"Kafka\\\"," 2021-06-24 15:54:16,086 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 java.text.SimpleDateFormat; import org.apache.jmeter.protocol.http.sample . . . ‘’ Token Parsing Error: Lexical error at line 11, column 77. Encountered: “\n” (10), after : “”{\“forwarderKey\”: \“zoeOPERADERBYTEST9188\”,\“type\”: \“Kafka\”,"