Pages

Saturday, August 17, 2024

Dynamically load jndi.properties when JMeter is running

An approach to having all test configurations in one place is using the jndi.properties file of JMeter.

When maintaining many JMeter test suites, it's convenient to have the jndi.properties placed together with the JMX file, then when you need to run the test file, you copy the associated jndi.properties into the JMeter bin directory. But this becomes a pain when switching to different test suites, as you will have to replace the jndi.properties with the new one.

Here I explain how to load the jndi.properties file from the same path as the JMX file, without copying the file into the JMeter bin directory. Also opening JMeter directly by opening the JMX file.

  • Open the jmeter-t.cmd file located in the bin folder of JMeter in a text editor.
  • Find the call to the jmeter command, typically at the end of the file and looks like this:
    call "%~dp0"jmeter -j "%~n1.log" -t "%~nx1" %2 %3 %4 %5 %6 %7 %8 %9
  • Modify it to add the Juser.classpath parameter to point to the bin folder of the JMeter (%~dp0 variable) and the path of the JMX folder (%~dp1 variable):
    call "%~dp0"jmeter -j "%~n1.log" -t "%~nx1" -Juser.classpath=%~dp0;%~dp1 %2 %3 %4 %5 %6 %7 %8 %9
  • Save the changes and close the file.
  • Update the associated default application with *.jmx files:
    • Right-click any JMX file and choose Properties from the context menu.
    • From the General tab, click the Change button to change the application that opens JMX files.
    • From the dialogue, navigate to the bin folder of JMeter and select jmeter-t.cmd.

Now you can open any JMX file in JMeter by double-clicking it, supposing the jndi.properties is located in the same folder, it will be loaded with the test.

Dynamically load jndi.properties when JMeter is running

An approach to having all test configurations in one place is using the jndi.properties file of JMeter. When maintaining many JMeter test su...