I'm new to jmeter, and I'm finding it very difficult to solve this error:
jmeter.util.BeanShellInterpreter: Error invoking bsh method:
eval Could not initialize class stpl.lib.enc.tea.TEALib
I have added the jar file of the java class in the lib/ext of the jmeter. I'm trying to import the java class in the beanshell preprocessor. The package name is stpl.lib.enc.tea and the class name is TEALib so used the synatx:
import stpl.lib.enc.tea.TEALib;
TEALib t = new TEALib();
String x = "ABCD";
vars.put("p2",x);
Also I have added a dll file in the java class which is also named as TEALib. So sometimes I also get the error saying no TEALib found in class.library.path.
The jmeter throws the two errors above.
First put your jar in jmeter/lib not jmeter/lib/ext.
Second , ensure you fill in :
-Djava.library.path=
Related
Hi I Have enviornment specific yaml files in my Mule Application . I need to read these file in my Java Class . My Yaml File name will be formed as
properties/${mule.env}/config-${mule.env}.yaml
So for each env it will load speicfic file. I need to get the respective env file in my java class . How i can do that . I tried like below in Java Class but its coming as null
#Value("${rixml.VersionID}")
private String version;
You can form the YAML filepath in your mule flow and then pass it as an argument to your java class.In your java class you can read the YAML file(from the file path passed to it), parse it and extract the value that you want.
File is getting download in jmeter bin folder from 'Save Responses to a file' assertion.
I'm not able to verify the downloaded file, Is there any assertion available other than MD5Hex Assertion or I need to write JAVA/Groovy code?
If you need to check file presence you can add a JSR223 Assertion and use the following code assuming File.exists() function :
if (!new File('Bulk.pdf').exists()) {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('File is absent')
}
If the file will not be present you will get an error message like:
More information: Scripting JMeter Assertions in Groovy - A Tutorial
You can check using notExists with more readable version
import java.nio.file.*;
if (Files.notExists(Paths.get("Bulk.pdf"))) {
I am new to Java Modularity. I am using Java 9.
The program compiles without complaint. It also runs perfectly well from the "exploded module" folder, but with one exception: it throws an exception whose cause originates with the following line of code:
URL introURL = AboutPanel.class.getResource("help.html");
introURL is being assigned null.
When running the program in Eclipse, or from a jar file exported from Eclipse, the URL is populated correctly with the address of a resource file (help.html) that is in the same directory as the calling class.
Here is the command I use to run the program from the "exploded module" that is in the "out" folder:
java -p out/ -m moduleTCD/com.adonax.tanpura.TCDLaunch
The project consists of two packages that I am bundling together in a single module.
src/moduleTCD/com/adonax/tanpura
/pfaudio
The "main" class (entry point) is tanpura.TCDLaunch.
Here is the module-info.java class contents:
module moduleTCD {
exports com.adonax.tanpura;
requires java.base;
requires java.desktop;
}
The error statement, when trying to run from the command line:
java.io.IOException: invalid url
at java.desktop/javax.swing.JEditorPane.setPage(Unknown Source)
at moduleTCD/com.adonax.tanpura.documentation.AboutPanel.<init>(AboutPanel.java:28)
at moduleTCD/com.adonax.tanpura.panels.ControlPanel.initializeHelpPanel(ControlPanel.java:525)
at moduleTCD/com.adonax.tanpura.panels.ControlPanel.<init>(ControlPanel.java:163)
at moduleTCD/com.adonax.tanpura.TCDLaunch.main(TCDLaunch.java:43)
This exception is thrown in a try/catch for IOException at the point where the JEditorPane method setPage is called with null as an argument.
textArea.setPage(introURL);
At first, I didn't have an exports line in my module-info.java, but added it when I read the following from the API for Class.getResource:
Returns:
A URL object; null if no resource with this name is found, the resource cannot be located by a URL, the resource is in a package that
is not open to at least the caller module, or access to the resource
is denied by the security manager.
This raised the possibility that the package might be needed by Class in the module Java.base. The exports command there now is the broadest possible. But adding it did not change the error. I'm wondering if there is something wrong with how I did this, or if there is something else I am overlooking.
Classic error on my part. I made assumptions about the error being related to tech that is new and unfamiliar to me, rather than first verifying the obvious.
The fail was due to not realizing that the javac command did not move required resources into the target folder system.
I also verified that an "exports" statement is NOT needed in module-info in order to allow the loading of the resource.
So, in fact, this was not a java-module issue at all, just an oversight which I credit in part to a lack of chops using shell-level Java commands.
Big thank you to Alan Bateman!
I have an issue when using Jmeter BeanShell preprocessor.
The script invoke jars which I have put them under directory "D:\Software\apache-jmeter-3.0\lib\ext".
enter image description here
here is my BeanShell code:
import com.evergrande.api.test.JsonClientUtil;
import com.evergrande.common.utils.JsonUtil;
import com.fasterxml.jackson.databind.node.ObjectNode;
JsonClientUtil jcu=new JsonClientUtil();
ObjectNode node = JsonUtil.createObjectNode();//when I try to use the method in JsonUtil(Class),it came out error
Error:
2016/09/24 22:48:06 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import com.evergrande.api.test.JsonClientUtil; import com.evergrande.common.util . . . '' : Typed variable declaration : Method Invocation JsonUtil.createObjectNode
2016/09/24 22:48:06 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import com.evergrande.api.test.JsonClientUtil; import com.evergrande.common.util . . . '' : Typed variable declaration : Method Invocation JsonUtil.createObjectNode
I can invoke "createObjectNode" method in my java Code.
So,how can I fix this issue? Thank you all.
Don't put any jars to the lib/ext folder, it should be used for JMeter core components and plugins only. Put your .jar libraries to "lib" folder of somewhere else, they just need to be on the JMeter's Claspath. Alternative option is using Add directory or jar to classpath option on Test Plan level
JMeter restart is required to pick the jars up.
You can get more readable Beanshell error message by surrounding your code with try/catch block like
import com.evergrande.api.test.JsonClientUtil;
import com.evergrande.common.utils.JsonUtil;
import com.fasterxml.jackson.databind.node.ObjectNode;
try {
JsonClientUtil jcu=new JsonClientUtil();
ObjectNode node = JsonUtil.createObjectNode();
}
catch (Throwable ex) {
log.error("Beanshell failure: ", ex);
throw ex;
}
So if your script fails you will be able to see stacktrace details in the jmeter.log file. Another approach of getting to the bottom of your Beanshell script failure is adding debug(); command to the beginning of your script. It will trigger verbose output to the console. Check out How to Debug your Apache JMeter Script article for more information on JMeter debugging techniques.
I am using the Spring boot for an Java application and I want to put a python module my_module.py in the the app. I am trying to import the module like
interpretor.exec("import my_impodule")
But I am getting the error ImportError: No Module named my_module and when I check the current working directory using
interpretor.exec("import os\nprint os.getcwd()")
which gave me the path /my_project/ and my module location is /my_project/my_module.py which is correct. It should pick up the module if current working directory is this.
Can someone please help me where to put the python module so that I can picked up by Jython.
You need to set the Python module path. So that it can pick your module like this:
Properties pyProperties = new Properties();
pyProperties.put("python.path", System.getProperty("user.dir") + MODULE_PATH);
PythonInterpreter.initialize(System.getProperties(), pyProperties(), new String[0]);
PythonInterpreter pyInterpreter = new PythonInterpreter();