Search code examples
jmeterbeanshell

Jmeter Beanshell error


i am getting following error

     ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval  In file: inline evaluation of: ``import java.text.*; import java.io.*; import java.util.*; import org.apache.jmet . . . '' Encountered "/" at line 15, column 74.

could anyone tell what is causing the problem.Thanks.


Solution

  • You can use the following approaches to debug your Beanshell script:

    1. Add debug(); line at the beginning of your script and inspect STDOUT so you will be able to see what exactly goes on
    2. Add extra logging like log.info("something"); so you will be able to determine which lines are fine and where execution stops by looking into jmeter.log file
    3. Wrap your code into try/catch block as follows:

      try {
          //your Beanshell code here
      } catch (Exception ex) {
          log.info("Script execution failed", ex);
      }
      

    Exception details will be printed to jmeter.log file, it's much more informative than Error invoking bsh method one.

    See How to use BeanShell: JMeter's favorite built-in component guide for more tips and tricks.