【发布时间】:2014-06-27 17:19:55
【问题描述】:
嘿,我正在为 jmeter 中的 Web 应用程序编写一些 beanshell 脚本。我已经编写了很多嵌入了 beanshell 的 jmeter 脚本,出于某种原因,这个脚本一直给我关于 Integer.parseInt() 方法调用的错误。
这是错误:
2014/06/27 10:08:58 错误 - jmeter.util.BeanShellInterpreter:调用 bsh 方法时出错:eval 源文件:内联评估:
import java.io.*; import java.util.*; int containerCount = 0; int secondVal = . . . '' : Method Invocation Integer.parseInt 2014/06/27 10:08:58 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of:import java.io.;导入 java.util.; int 容器计数 = 0;整数秒值 = 。 . . '' : 方法调用 Integer.parseInt
下面列出了我的所有 Integer.parseInt() 调用,它们对我来说似乎都很合理,如果有人是 beanshell 专家并且可以帮助我识别错误,那就太好了,谢谢!
int containerCount = 0;
int secondVal = 0;
int BPNumSelected = 0; //Branch Plant only is in response page with more than one container, in the site shipment but must be initialized to something here.
boolean mult = false; //Boolean to see if the site shipment has more than one container
String ScontainerCount= vars.get("availableQty_matchNr");
String SsecondVal = vars.get("secondVal");
if(ScontainerCount!=null)
containerCount = Integer.parseInt(ScontainerCount); //refers to the number of containers in that site shipment
if(SsecondVal!=null)
secondVal = Integer.parseInt(SsecondVal); //A weird value that is passed in the parameter name after selectedLotID,
if(vars.get("BPNumSelected")==null){
vars.put("BPNumSelected","0");
}
if(containerCount>1){
String SBPNumSelected = vars.get("BPNumSelected");
BPNumSelected = Integer.parseInt(SBPNumSelected); //gets the branch plant ID if more than one container
mult = true;
}
还有……
SlocPackedQtyValue = vars.get("locPackedQtyValue");
SavailQtyNoComma = vars.get("availQtyNoComma");
if(vars.get("locPackedQtyValue")!=null)
packedQtyVal = Integer.parseInt(SlocPackedQtyValue);
if(vars.get("availQtyNoComma")!=null)
availableRoom = Integer.parseInt(SavailQtyNoComma);
【问题讨论】:
-
编辑:它对所有线程重复错误
-
您能否偶然解决这个问题?我在stackoverflow.com/questions/24462367/… 遇到了同样的问题
-
通过仔细检查所有字符串在方法调用时是否具有值,并通过仔细检查所有字符串是否在任何循环或类似的东西之外声明。对我来说似乎有点过于谨慎了。我会在下面使用 olyv 的答案,'${}' 分配在 beanshell 中对我来说也很有效。