Let me give a bit of background.
As you can see, two variables are defined that point to two different *.ini files using the following value:
${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__BeanShell(File.separator,)}Settings.ini
for variable: SettingsFile
Using Step-by-step debugger, I can confirm that the path to the files is correct. Now, the fun part. I have few "User Defined Variables" that read values from the files.
JMeter cannot read values for this variables and throws the following error for each one of them:
using (e.g): for variable accountNumber
2018-02-20 15:15:46,750 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``{import org.ini4j.*; Wini ini = new Wini(new File(vars.get("SettingsFile"))); St . . . '' : Typed variable declaration : Class: Wini not found in namespace
2018-02-20 15:15:46,751 WARN o.a.j.f.BeanShell: Error running BSH script
org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``{import org.ini4j.*; Wini ini = new Wini(new File(vars.get("SettingsFile"))); St . . . '' : Typed variable declaration : Class: Wini not found in namespace
at org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:183) ~[ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.util.BeanShellInterpreter.eval(BeanShellInterpreter.java:189) ~[ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.functions.BeanShell.execute(BeanShell.java:100) [ApacheJMeter_functions.jar:3.3 r1808647]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:137) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:112) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:92) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:281) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.config.Argument.getValue(Argument.java:146) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.config.Arguments.getArgumentsAsMap(Arguments.java:94) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.engine.PreCompiler.createArgumentsMap(PreCompiler.java:114) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jmeter.engine.PreCompiler.addNode(PreCompiler.java:101) [ApacheJMeter_core.jar:3.3 r1808647]
at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:996) [jorphan.jar:3.3 r1808647]
at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:978) [jorphan.jar:3.3 r1808647]
at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:369) [ApacheJMeter_core.jar:3.3 r1808647]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
at org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:166) ~[ApacheJMeter_core.jar:3.3 r1808647]
... 14 more
Caused by: bsh.EvalError: Sourced file: inline evaluation of: ``{import org.ini4j.*; Wini ini = new Wini(new File(vars.get("SettingsFile"))); St . . . '' : Typed variable declaration : Class: Wini not found in namespace
at bsh.BSHAmbiguousName.toClass(BSHAmbiguousName.java:74) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.BSHType.getType(BSHType.java:154) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.BSHTypedVariableDeclaration.eval(BSHTypedVariableDeclaration.java:75) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.BSHBlock.evalBlock(BSHBlock.java:130) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.BSHBlock.eval(BSHBlock.java:80) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.BSHBlock.eval(BSHBlock.java:46) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.Interpreter.eval(Interpreter.java:645) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.Interpreter.eval(Interpreter.java:739) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at bsh.Interpreter.eval(Interpreter.java:728) ~[bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
at org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:166) ~[ApacheJMeter_core.jar:3.3 r1808647]
... 14 more
The Settings.ini looks like (taken accountNumber as an example):
[General]
;account number used for testing
accountNumber = 989899773
;BadAccountNumber = 12314500
BadAccountNumber = 989899773
Any ideas on how to get rid of this error? I do not understand why I cannot read the values for each variable if the path to the file is correct.
PS: I don't get any results in "View Results Tree". All tests are simple HTTP requests using variables from the files.
This is due to missing ini4j library, you need to download the .jar, put it somewhere to JMeter Classpath and restart JMeter to pick the .jar up.
Also be aware that starting from JMeter 3.1 it is recommended to use JSR223 Test Elements and __groovy() function for any form of scripting in JMeter. So consider to moving to Groovy on next available opportunity. More information: Apache Groovy - Why and How You Should Use It