错误-jmeter.util.BeanShellInterpreter:调用bsh方法时出错:eval源文件:对以下内容的内联评估: [英] ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of:

查看:2015
本文介绍了错误-jmeter.util.BeanShellInterpreter:调用bsh方法时出错:eval源文件:对以下内容的内联评估:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行具有Beanshell Post Processor作为采样器子级的jmeter脚本时,出现以下错误.

Getting below error when i run the jmeter script having Beanshell Post Processor as a child to a sampler.

错误-jmeter.util.BeanShellInterpreter:调用bsh方法时出错: eval源文件:内联评估:``尝试{newuser = vars.get("prevUsrResponse"); org.json.JSONObject userJSON = new o. . . '':类型变量声明:类:找不到org.json.JSONObject 在命名空间中

ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``try { newuser= vars.get("prevUsrResponse"); org.json.JSONObject userJSON= new o . . . '' : Typed variable declaration : Class: org.json.JSONObject not found in namespace

下面是在jMeter 2.9中编写并运行的代码.

Below is the code written and run in jMeter 2.9.

newuser= vars.get("prevUsrResponse");
org.json.JSONObject userJSON= new org.json.JSONObject(newuser);

if(prevUsrJSON.has("User") && custJSON.get("User")!= null) {
   org.json.JSONObject contactJSON = userJSON.getJSONObject("User");

  contactJSON.put("UserType","Private");

}

vars.put("updatedUser", userJSON.toString());

${updatedUser}变量在下一个采样器请求中使用时不返回json(或任何值).

${updatedUser} variable doesn't return the json(or any value) when used in the next sampler request.

推荐答案

可能有以下几种原因:

  1. 您没有在JMeter CLASSPATH中提供org.json.JSONObject类的.jar.

  1. You don't have the .jar which provides org.json.JSONObject class in JMeter CLASSPATH.

  • Maven中央存储库
  • 下载jar
  • 将其复制到JMeter的"lib"文件夹中
  • 重新启动JMeter来拾取.jar
  • Download the jar i.e. from the Maven central repo
  • Copy it to JMeter's "lib" folder
  • Restart JMeter to pick the .jar up

您没有相关的导入行.将其添加到脚本的开头:

You dont have the relevant import line. Add it to the beginning of your script:

import org.json.JSONObject;

您还可以考虑升级到 JMeter 3.0 ,它具有内置的JSON支持,并提供 JSON路径PostProcessor 从JSON响应中提取数据.如果您仍然想要Beanshell-也可以,只需使用 json-smart

You can also consider upgrading to JMeter 3.0 which comes with built-in JSON support and provides JSON Path PostProcessor to extract data from JSON responses. If you still want Beanshell - it is also possible, just use json-smart classes

这篇关于错误-jmeter.util.BeanShellInterpreter:调用bsh方法时出错:eval源文件:对以下内容的内联评估:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆