JMeter - Exception when using Beanshell as JSR223 Sampler with file

user7294900

I have a file with simple JSR223 code:

log.info("Hello JSR223")

When I choose Beanshell as language in JSR223 Sampler I get the following exception:

2018-06-21 10:32:28,148 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 script JSR223 Sampler, message: javax.script.ScriptException: In file: eval stream Encountered "<EOF>" at line 2, column 24.
 in eval stream at line number 2
javax.script.ScriptException: In file: eval stream Encountered "<EOF>" at line 2, column 24.
 in eval stream at line number 2
    at bsh.engine.BshScriptEngine.evalSource(BshScriptEngine.java:82) ~[bsh-2.0b6.jar:2.0b6 2016-02-05 05:16:19]
    at bsh.engine.BshScriptEngine.eval(BshScriptEngine.java:52) ~[bsh-2.0b6.jar:2.0b6 2016-02-05 05:16:19]
    at javax.script.AbstractScriptEngine.eval(Unknown Source) ~[?:1.8.0_25]
    at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:199) ~[ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:69) [ApacheJMeter_java.jar:4.0 r1823414]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490) [ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416) [ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) [ApacheJMeter_core.jar:4.0 r1823414]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]

Same code work without file by adding to Script field

Dmitri T

If you use Beanshell you need to stick to Java SE 5.0 syntax to wit your statement needs to end with semicolon, amend it to look like:

log.info("Hello JSR223");
//                      ^ this is uber important

and your script should start working as expected.

Be aware that starting from JMeter 3.1 it is recommended to use Groovy language for scripting mainly because Groovy has much better performance comparing to Beanshell so I would suggest keeping "Language" as groovy, in this case the semicolon is not necessary.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

upload a file using jsr223 sampler getting failure on JMeter

JMeter - Error when using Jython/Python Engine in JSR223 Sampler "Cannot find Engine"

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

Jmeter JSR223 Sampler - Unable to Write Data To CSV File

Read json file in jsr223 sampler in jmeter and extract data

Create JMeter Test Plan using JSR223 Sampler

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

JMeter - groovy MultipleCompilationErrorsException in JSR223 Sampler

File declaration throwing error in JMeter, JSR223 sampler with groovy script

Error when trying to execute existing Jmeter script in Maven project that is written in Jsr223 sampler in groovy

Jmeter - declare array variable in one JSR223 Sampler in order to access it in another JSR223 Sampler

JMeter Javascript language not available for JSR223 Sampler and WebDriver Sampler

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

Problem in JSR223 script JSR223 Sampler, while connecting to Azure Cosmos DB from Jmeter

JMeter - Calling HTTP samplers in JSR223/BeanShell samplers

JMeter - JSR223 Sampler missing character encoding

JMeter - Access JSR223 variable in HTTP sampler

Generate random values in JSR223 sampler in JMeter

Code in JMeter JSR223 Sampler comments is executed

How to update User Defined Variable in JMeter in JSR223 Sampler?

"Precondition Failed" for post request in JSR223 Sampler in JMeter

JMeter Beanshell sampler that runs when HTTP Request Sampler fails

Validate the response from JDBC request using beanshell or JSR223

JMeter Load Tesing::Moving from WebDriver sampler To JSR223 sampler with groovy

Scala JSR223 script using JMeter/Java context

API Jmeter request modification upon using JSR223 PreProcessor

JSR223 PreProcessor generates invalid format using Groovy in Jmeter

getting response times using JSR223 + JMeter

Jmeter - Using varible: from JDBC request into JSR223 PostProcessor