2016-09-24 96 views
0

使用Jmeter BeanShell预处理器时遇到问题。 该脚本调用了我将它们放在目录“D:\ Software \ apache-jmeter-3.0 \ lib \ ext”下的jar。 enter image description hereJmeter输入变量声明:方法调用

这里是我的BeanShell代码:

import com.evergrande.api.test.JsonClientUtil; 
import com.evergrande.common.utils.JsonUtil; 
import com.fasterxml.jackson.databind.node.ObjectNode; 

JsonClientUtil jcu=new JsonClientUtil(); 
ObjectNode node = JsonUtil.createObjectNode();//when I try to use the method in JsonUtil(Class),it came out error 

错误:

2016/09/24 22:48:06 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import com.evergrande.api.test.JsonClientUtil; import com.evergrande.common.util . . . '' : Typed variable declaration : Method Invocation JsonUtil.createObjectNode 
2016/09/24 22:48:06 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import com.evergrande.api.test.JsonClientUtil; import com.evergrande.common.util . . . '' : Typed variable declaration : Method Invocation JsonUtil.createObjectNode 

我可以调用我的Java代码 “createObjectNode” 的方法。 那么,我该如何解决这个问题?谢谢你们。

回答

0
  1. 不要把任何罐子到lib/ext文件夹,它应该只用于JMeter的核心组件和插件。将你的.jar库放到其他地方的“lib”文件夹中,他们只需要在JMeter's Claspath上。另一种选择是使用上Test Plan水平Add directory or jar to classpath选项

    extra jars to classpath

  2. JMeter用户需要重新启动来接的罐子了。
  3. 您可以通过周围的你的代码try/catch块获得更易读BeanShell的错误消息像

    import com.evergrande.api.test.JsonClientUtil; 
    import com.evergrande.common.utils.JsonUtil; 
    import com.fasterxml.jackson.databind.node.ObjectNode; 
    
    try { 
        JsonClientUtil jcu=new JsonClientUtil(); 
        ObjectNode node = JsonUtil.createObjectNode(); 
    } 
    catch (Throwable ex) { 
        log.error("Beanshell failure: ", ex); 
        throw ex; 
    } 
    

    所以,如果你的脚本失败,你将能够看到jmeter.log文件堆栈跟踪信息。让您的Beanshell脚本失败的另一种方法是在脚本的开头添加debug();命令。它会触发详细的输出到控制台。查阅How to Debug your Apache JMeter Script文章以获取有关JMeter调试技术的更多信息。

+0

谢谢!我已经解决了这个问题。这是因为缺乏Jar包。 – TavisD