2016-09-24 15 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フォルダに任意のjarファイルを入れないでください、それはJMeterのコアコンポーネントのみプラグインを使用する必要があります。あなたの.jarライブラリを他の場所の "lib"フォルダに入れてください。ちょうどJMeter's Claspathである必要があります。代替オプションは

    extra jars to classpath

  2. のJMeterの再起動が瓶を拾うために必要とされるTest PlanレベルでAdd directory or jar to classpathオプションを使用しています。
  3. スクリプトがあなたがjmeter.logファイルにスタックトレースの詳細を見ることができます失敗した場合、あなたはとても

    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; 
    } 
    

    ようtry/catchブロックでコードを囲むことで、より読みやすいBeanShellのエラーメッセージを取得することができます。 Beanshellスクリプトの失敗の最下部に到達するもう1つの方法は、スクリプトの先頭にdebug();コマンドを追加することです。これは、コンソールに冗長出力をトリガします。 JMeterのデバッグ手法の詳細については、How to Debug your Apache JMeter Scriptの記事を参照してください。

+0

ありがとうございます!私はこの問題を解決しました。それはJarパッケージの欠如のためです。 – TavisD

関連する問題