You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by sebb <se...@gmail.com> on 2007/12/19 18:44:40 UTC

Re: Reference on beanshell.init.file

On 19/12/2007, Sebastian Straus <su...@gmx.de> wrote:
> Hello Community,
>
> I try to explain my problem with a simple sample.
> The beanshell.init.file looks like this:

beanshell.init.file is used for running a script at startup. It is not
passed to any of the test elements.


> ---------------------------------------------------------
> ---------------------------------------------------------
> //Example for BeanShell Init-File
> System.out.println("Start of the BSH-Init-File");
>
> String trial=new String("I want to be seen in all BSHs");
>
> String getTrial()

Does not return a String.

> {
>        System.out.println(trial);
> }
> System.out.println("End of the BSH-Init-File");
> ---------------------------------------------------------
> ---------------------------------------------------------
>
> I try to get access on the variable (in a BSH Sampler, BSH
> Preprocessor, BSH Postprocessor) with
> ---------------------------------------------------------
> import bsh.Interpreter;

Not needed.

> System.out.println(this.trial);
> ---------------------------------------------------------
> but I always get the following Error-Message:
> ---------------------------------------------------------
> Response message: org.apache.jorphan.util.JMeterException:
> Error invoking bsh method: eval
> Sourced file: inline evaluation of:
> ''import bsh.Interpreter; System.out.println(this.trial);":
> Undefined argument: this.trial

Because you used the wrong init file property.

> ---------------------------------------------------------
> ---------------------------------------------------------
>
> When I try to get response from the method (in a BSH Sampler, BSH
> Preprocessor, BSH Postprocessor)
> ---------------------------------------------------------
> System.out.println(this.getTrial());
> ---------------------------------------------------------
>  the error message looks like this:
> ---------------------------------------------------------
> Response message: org.apache.jorphan.util.JMeterException:
> Error invoking bsh method: eval
> Sourced file: inline evaluation of:
> ''import.bsh.Interpreter; System.out.println(this.getTrial())...":
> Method getTrial() not found in bsh scripted object: global
> ---------------------------------------------------------
> Is there anyone who knows how I can recieve access to the methods and
> variables?

Use the correct init file properties:

#beanshell.sampler.init=BeanShellSampler.bshrc
#beanshell.function.init=BeanShellFunction.bshrc
#beanshell.assertion.init=BeanShellAssertion.bshrc
#beanshell.listener.init=etc
#beanshell.postprocessor.init=etc
#beanshell.preprocessor.init=etc
#beanshell.timer.init=etc

Please note that the each test element in each thread has its own
interpreter, so you can't use Beanshell variables to communicate
between elements or threads.

> Thank you very much
>
> Sebastian
> --
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org