Error in Beanshell Sampler JMeter for parsing RegularExpressionExtractor

Jatin

Setting below sample result in jar file

mySampleResult.setResponseData("ReturnCode" + returnCode + "EndReturnCode" ,null);

copy the jar file in lib/ext of JMeter.

Create a project where Regular expression extractor is attached to java request which calls runtest in jar file

Response string is below

ReturnCodeThu Feb 16 08:01:56 GMT 2017,Thu Feb 16 09:09:27 GMT 2017,0:1:7:31,98.74105EndReturnCode

Regular Expression Extractor

Reference Name: returnValue
Regular Expression: ReturnCode(.*?)EndReturnCode

Beanshell Code

 ${returnValue}

Error in Beanshell

Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval  In file: inline evaluation of: ``  try {     Thu Feb 16 08:01:56 GMT 2017,Thu Feb 16 09:09:27 GMT 2017,0:1:7:31,9 . . . '' Encountered "16" at line 4, column 13.

Please let me know that why I am getting this error.

Dmitri T

Your ${returnValue}statement is syntaxically incorrect, you need at least to surround it with quotation marks like "${returnValue}" so Beanshell interpreter would treat it as a Java String

Going forward, just putting this statement inside the Beanshell Sampler doesn't make any sense, you should add some further processing, i.e:

  • return "${returnValue}"; - will set Beanshell Sampler result to this value
  • SampleResult.setResponseData("${returnValue}".getBytes()); - the same as above but using SampleResult shorthand
  • print("${returnValue}"); - output the value to STDOUT
  • log.info("${returnValue}"); - output the value to jmeter.log file

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Parsing string to integer in BeanShell Sampler in JMeter

Jmeter, BeanShell Sampler and Summary Report

JMeter Beanshell sampler that runs when HTTP Request Sampler fails

JMeter Beanshell Integer Error

JMeter - Exception when using Beanshell as JSR223 Sampler with file

Unable to append to next line in a file through beanshell assertion sampler in Jmeter

Store Jmeter sampler properties value using beanshell preprocessor

Writing Variables using Beanshell Sampler in JMeter into a txt/csv file

JMeter WebDriver Sampler Error for Java

Jmeter: Access all results from all threadGroups from JSR223 Sampler or BeanShell Sampler in TeardownThread

JMETER (Beanshell): Token Parsing Error: Lexical error at line 4, column 25. Encountered: "u" (117), after : "\'s"

Jmeter - Inline evaluation error in Beanshell Assertion

Error on accessing Output Variable in beanshell preprocessor in Jmeter

Jmeter Webdriver sampler error for Firefox web driver

Error running sampler with http request- Jmeter

Get error when run WebDriver Sampler in jmeter

Jmeter BeanShell assertion parsing and comparing UTC datetime from json

JMeter saving document to MongoDb with Java BeanShell: Problem in JSR223 script Sampler

In Jmeter how do I set a variable number of threads using a beanshell sampler variable?

How to get Sampler Body data from beanshell Pre-Processor - JMeter

Encountered "=" error in Jmeter when List is used in jmeter beanshell code

JMeter / Beanshell "Error invoking bsh method: eval Sourced file:"

JMeter BeanShell Assertion: Getting error when convert String to Long

No such element error from Web Driver sampler in Jmeter while running headless

Jmeter and global Beanshell variables

Update Jmeter variables with beanshell

Jmeter. BeanShell PostProcessor

Jmeter beanshell Post Processor

JMeter simple BeanShell PreProcessor