Typed variable declaration : Void initializer error in beanshell sampler Jmeter

4.4k Views Asked by At

Hi I am trying to pass a a value from one regex extractor of one HTTP request to a beanshell sampler like below.

 var linkArr= ${PlanLinksArray_1}

Now I am using this linkArr variable in the subsequent request in the path like below

/hix/admin/planmgmt/viewqhpdetail/${linkArr}

While trying to do so I am getting the below error. The step fails at beanshell sampler with below error.

Can someone kindly advise ??

2015/06/12 16:32:10 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 
2015/06/12 16:32:11 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   Sourced file: inline evaluation of: ``var linkArr= hrGBCoZUbjLEV7zGwJpxEw ;'' : Typed variable declaration : Void initializer. 
2015/06/12 16:32:11 WARN  - jmeter.protocol.java.sampler.BeanShellSampler: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``var linkArr= hrGBCoZUbjLEV7zGwJpxEw ;'' : Typed variable declaration : Void initializer.
1

There are 1 best solutions below

0
On

Out of interest, why do you need Beanshell instead of calling ${PlanLinksArray_1} directly in the subsequent request?

In regards to your question itself, Beanshell is more Java rather than JavaScript hence correct code will be something like:

String linkArr = vars.get("PlanLinksArray_1");
vars.put("linkArr", linkArr);

Where vars is a shorthand to JMeterVariables class instance.

See How to use BeanShell: JMeter's favorite built-in component guide for more information on Beanshell scripting in JMeter.