1
votes

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

1

1 Answers

1
votes

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.