草稿~!
下载GSon:http://mvnrepository.com/artifact/com.google.code.gson/gson
下载
遇到问题:
org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.sql.*; import java.util.*; import java.lang.*; import org.apac . . . '' : Typed variable declaration
Typed variable declaration : Class: JSONObject not found in namespace
引入:Java-json.jar,gson.jar
将包放入Jmeter安装目录lib文件下
Typed variable declaration
类型出错,可以使用以下代码,将错误信息写入log文件,查看错误详细信息
try{ history = vars.get("frequency_info"); FailureMessage = "刚好获取数据库数据" ; response = prev.getResponseDataAsString(); } catch(Throwable ex){ log.error("Beanshell failure: ", ex); throw ex; }
org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.json.JSONObject; import com.google.gson.JsonObject; try{ history . . . '' : Undefined argument: historyObj
org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.sql.*; import java.util.*; import java.lang.*; //import org.apache.r . . . '' : Typed variable declaration : Constructor error: Can't find constructor: com.google.gson.JsonObject( java.lang.String ) in class: com.google.gson.JsonObject
排错:
类型转换错误、数据接收类型错误等等等等等等等等原因,挨着挨着一个一个调试吧,最近遇见大多属于这种情况。