0
votes

I have stuck with below error in jmeter.

Response code: 500 Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of'

bean shell code:

import tools.JmeterTools; 

JmeterTools jt = new JmeterTools();  

int num = Integer.parseInt(vars.get("A1"));

num = jt.randInt(num);  

vars.put("A1", num.toString());  

num =  Integer.parseInt(vars.get("B1")); 

num = jt.sqrInt(num);   

vars.put("B1", num.toString());  

vars.put("B2", jt.sqrstr(vars.get("B2")));  

}

eclipse code:

package tools;
import java.util.Random;

public class JmeterTools {

    public JmeterTools(){
    }

    public int randInt (int x){
        Random randomGenerator= new Random();
        return randomGenerator.nextInt(x);
    }

    public int sqrInt(int x){
        return x*x;
    }

    public String sqrstr(String x){
        int y= Integer.parseInt(x);
        return String.valueOf(y*y);
    }

}
1
Is there really a closing paranthesis at the end of your BeanShell code? - Jan
no, that paranthesis is for try and catch block - Ravi Varanasi

1 Answers

1
votes

Did you:

  • export your JmeterTools class as a JAR
  • Is the JAR OK ?
  • put the JAR in jmeter/lib folder ?

Also, you have a } at end of your beanshell code that shouldn't be there.