How to execute java class in jar file from Jmeter -


i fresher in jmeter have created 2 class as

*package test; public class urlmap {     static string turl=null;     public string display(){         string url="/xyz";         test2 t=new test2(url);         turl=t.x;         return "/xyz";      } } package test; public class test2 { static string x=null; test2(string x){     this.x=x; }    }* 

i have imported jar trying execute class in beanshell sampler of jmeter

import test.urlmap; urlmap u =new urlmap(); log.info("xxxxxxxxxxxx :----"+u.display()); log.info("turl :----"+u.turl); 

it giving me error --error invoking bsh method: eval sourced file: inline evaluation of: import test.urlmap; urlmap u =new urlmap(); log.info("xxxxxxxxxxxx :----"+u.di . . . '' : cannot access field: turl, on object: test.urlmap@16ec122a 2017/07/28 06:44:56 warn - jmeter.protocol.java.sampler.beanshellsampler: org.apache.jorphan.util.jmeterexception: error invoking bsh method: eval sourced file: inline evaluation of:import test.urlmap; urlmap u =new urlmap(); log.info("xxxxxxxxxxxx :----"+u.di . . . '' : cannot access field: turl, on object: test.urlmap@16ec122a

but working fine in eclipse. is jmeter can access 1 class value @ time not nested class value .

the problem is, turl field has scope of package protected: visible in package test, not jmeter's package.

solution: replace static public.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -