I am trying to execute the following Beanshell script in JMeter and it throws an error in the log. The script is:
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
Cookie cookie = new Cookie("ApiSession",props.get("MyCookie"),"","/",false,0);
manager.add(cookie);
The error in the log file is:
jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.protocol.http.control.CookieManager; import org.apache. . . . ''
It is not happy with the line: manager.add(cookie);
If I comment it out, then the script runs, but obviously doesn't do what I want. So, not sure what the problem is.
It is not helpful that I can't see whole of the debug information. Jmeter log records only part of the actual error message (as above) and that message is cut in the middle. Switching on debugging mode doesn't help.
If you want to see full error message you'll need to surround problematic statement in try/catch block and print stacktrace to sdtout / log.
Particularly sharing cookies between thread groups use case is highlighted in How to use BeanShell guide.