Rahul
Rahul

Reputation: 11

Getting an error on writing a DB output value to a variable in jmeter

The syntax I used is props.put("perpetual_id",vars.get("Inventory_id_1"));

Response code: 500
Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval  Sourced file: inline evaluation of: ``props.put("perpetual_id",vars.get("Inventory_id_1")); System.out.println(vars.ge . . . '' : Method Invocation props.put

If I am using System.out.println(vars.get("inventoryId_1"));, it's printing fine.

Upvotes: 0

Views: 117

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

You probably have a typo, i.e. missing underscore in your props.put... statement.

Given System.out.println(vars.get("inventoryId_1")); works fine my expectation is that you need to change your line to something like:

props.put("perpetual_id",vars.get("inventoryId_1"));

Few more hints:

  • you can use bsh.shared namespaces as an alternative to JMeter Properties
  • you can get more human-friendly error message by putting your Beanshell code inside the try block like:

    try { 
        //your code here
    }
    catch (Throwable ex) {
        log.error("Error in beanshell", ex);
        throw ex;
    }
    

    This way you can get the "usual" stacktrace printed to jmeter.log file which will be way more informative and will help you to get to the bottom of the issue much faster and easier.

See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on using Beanshell in JMeter tests.

Upvotes: 1

Related Questions