Reputation: 658
I tried the following statements in the BeanShell PreProcessor
String groupName = ctx.getThreadGroup().getName();
groupName = "${__BeanShell(ctx.getThreadGroup().getName())}"
Both return the ERROR
jmeter.util.BeanShellInterpreter:
Error invoking bsh method: eval Sourced file:
inline evaluation of: ctx.getThreadGroup().getName();
However, they print the Thread Group name correctly.
Upvotes: 0
Views: 1737
Reputation: 168042
Your code looks good (at least this line), the problem seems to be somewhere else
Going forward you can use the following options to get to the bottom of your Beanshell script issue:
Put your code inside the try block like:
try {
String groupName = ctx.getThreadGroup().getName();
} catch (Throwable ex) {
log.error("Something went wrong", ex);
throw ex;
}
This way you will be able to see full error details in jmeter.log file
Add debug() command to the beginning of the Beanshell script - it will trigger debugging output to JMeter console window
See How to Debug your Apache JMeter Script article for more information on JMeter test script issues troubleshooting.
Upvotes: 2