相关文章推荐
傻傻的消炎药  ·  Power BI: ...·  3 月前    · 
性感的毛豆  ·  js ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams String[] lead = name_lead.split("\\s+"); //vars.put("myname",lead[0]); //vars.put("myname1",lead[1]); //vars.put("myname2",lead[2]); for(int i=1; i<=Integer.parseInt(vars.get("title_pass_matchNr")); i++) String title = vars.get("title_pass_"+i); String fname = vars.get("firstname_"+i); String lname = vars.get("lastname_"+i); String[] fn = fname.split(""); //vars.put("title",title); //vars.put("fname",fn[1]); //vars.put("lname",lname); if(lead[i-1].equals(title) && lead[i].equals(fn[1]) && lead[i+1].equals(lname)) vars.put("namep",lead[i]);

But I'm getting the following error:

Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.lang. ; import java.util. ; String name_lead=vars.get("Name_lead"); . . . ''

I'm not able to understand it. Can sombody help me? How do I fix this?

name_lead has something like Mr P singh ..and taking using regex extractor

value for name_lead ,im taking from he response using regex.that value is something like Mr P singh user6324058 Aug 5, 2016 at 4:17

There is a good way to convert this Error invoking bsh method error into a more human-readable stacktrace: put your code into a try block like:

try {
    //your code here
catch (Throwable ex) {
    log.error("Error in Beanshell", ex);
    throw ex;

This way you will able to see the exception details in jmeter.log file

Another way to add debug() directive at the very beginning of your Beanshell script. This way you'll get a lot of debugging output into stdout.

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

Sure but "Log & Throw" is generally not a good idea. It causes code smell. Instead, you either log OR throw. Doing both is redundant. – djangofan Dec 5, 2022 at 19:26

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.