I'm new to jmeter, and I'm getting 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 syntax:
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.
For .jar file - copy it to JMeter's /lib folder. JMeter restart is required to pick the .jar up
For .dll file - make sure it lives under one of the following locations:
somewhere in java.library.path
somewhere under system PATH
You may add folder where .dll file lives to java.library.path using one of the following approaches:
add the next line to system.properties file (located under /bin folder of your JMeter installation)
java.library.path=/path/to/folder/where/dll/lives
Again, JMeter restart is required to apply the property.
set it via -D command line argument as:
jmeter -Djava.library.path=/path/to/folder/where/dll/lives/ -t /your/testplan.jmx
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of working with them.
Related
My Spring Boot project contains an XML file within the src/main/resources folder, which is the common location for such a file.
Running locally and also on Pivotal CloudFoundary, I am able to locate the file and read it in, but on Beanstalk the process results in an empty file.
Code to locate and read file:
URL url = getClass().getResource("/myFile.xml");
LOG.info("File location: " + url.toString());
Resulting log entry:
File location: jar:file:/var/app/current/application.jar!/WEB-INF/classes!/myFile.xml
When I SSH into EC2 instance, I can find the jar in the specified directory.
Do I need to configure Maven to move this file somewhere?
UPDATE
I've since realized that I need to treat this file as in InputStream as it's packaged within the jar.
I'm now using the following code which results in the follow errors:
FileUtils.copyInputStreamToFile(new ClassPathResource("myFile.xml").getInputStream(), myFile);
java.lang.NullPointerException: null
at org.apache.commons.io.FileUtils.openOutputStream(FileUtils.java:345) ~[commons-io-2.5.jar:2.5]
and
FileUtils.copyInputStreamToFile(new ClassPathResource("classpath:myFile.xml").getInputStream(), myFile);
java.io.FileNotFoundException: class path resource [classpath:myFile.xml] cannot be opened because it does not exist
Thanks!
How does your pom.xml look like? Maybe there is a resource-filter active?
In a spring application you could use File file = ResourceUtils.getFile("classpath:myFile.xml"); to read a resource file.
Could you check the result by using ResourceUtils?
Here the link to the api-documentation:
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/ResourceUtils.html#getFile-java.lang.String-
I have created a Java project with 1 class containing 2 simple tests, exported as jar and added the jar in my JMeter JUnit folder, now after restarting the JMeter i don't see my class in JMeter even after selecting Annotation 4 option.
This is my class:
package print;
import org.junit.Test;
public class PrintClass {
#Test public void test() {
System.out.println("Hello World..!");
}
}
Consider the following checklist:
Your JUnit test class should have either empty constructor or constructor taking a single string as an argument. Other options are not supported
You should place your .jar file(s) under "lib/junit" folder of your JMeter installation
If there are any dependencies you need to put them somewhere in JMeter classpath as well
JMeter restart will be required to pick the .jars up
In case of any problems first of all check jmeter.log file (normally it lives under "bin" folder of your JMeter installation and contains enough troubleshooting information)
See How to Use JUnit With JMeter article for more details.
Even I faced same kind of issue then I added the dependency jars to the lib file.
Make sure you copy these files at this location -> apache-jmeter-5.1.1\lib
1.Selenium webdriver jar file (selenium-server-standalone)
2. Junit4 Jar file (junit4)
Make sure you add Jar file from eclipse or any IDE to this location -> apache-jmeter-5.1.1\lib\junit
1. Jar file which contains the automation selenium code (Using Junit)
Restart Jmeter and continue which the normal process of adding thread group and adding Junit sampler etc...
This resolved my issue and I was able to run my scripts on Jmeter.
In eclipse make sure that you create a JUnit class, not just the class and add junit annotations to this, even i was facing the same issue, it got resolved when i was created a JUnit class and then uploaded my project in JMeter
Did you put the jar in :
/lib/junit
Check you jar by running below command to see if it is ok:
jar -tvf <your jar>
And its dependencies as described in:
JUnit test classes not showing up in JMeter
See this for more details:
http://jmeter.apache.org/usermanual/junitsampler_tutorial.html
How to set class path in weblogic 11g console for classes present in web-inf/classes/
And my classes are in the below structure which needs to be set as class path to avoid exception which needs these classes to be loaded first.
/com/cdy/ws/a.class files
/com/cdy/ws/b.class files
/com/cdy/ws/c.class files
Please help,
Thanks
If you are looking for WebLogic specific...
Lets say your web application dependent jars defined as:
WS_CLASSPATH=/com/cdy/ws
set in your environment variable.
That means your weblogic server can be loaded with weblogic.jar its relavent jars then, your WS_CLASSPATH can be added in the setDomainEnv.sh/cmc script find the EXT_PRE_CLASSPATH and assign to it.
EXT_PRE_CLASSPATH=$WS_CLASSPATH
There will be opposite side of CLASSPATH after the weblogic specific libraries available with EXT_POST_CLASSPATH in the setDomainEnv script.
The startup or shutdown class must be on the classpath of each server to which it is assigned.
To add a class to a server's classpath, do one of the following:
If you use a script to start a server instance, open the script in a text editor. In the command that sets the classpath, add the pathname of the directory that contains your class root package.
Then restart the server.
For example, you create a startup class named StartBrowser in a package named com.mycompany.startup. You archive the class file in a JAR file named c:\myDomain\src\myJAR.jar.
The start script for your server must add c:\myDomain\src\myJAR.jar to the server's classpath.
If you use the Node Manager to start a server instance, do the following on each server that runs the startup class or shutdown class:
In the left pane of the Console, expand Environment and select Servers.
On the Servers page, click on the server name.
Select Configuration > Remote Start.
In the Classpath field, enter the pathname for the classes that WebLogic Server requires to be on the classpath.
Use an absolute pathname or a pathname that is relative to the Node Manager's home directory.
Separate multiple classes with the type of separator that your operating system or shell requires.
For example, on Windows, use ; (semicolon) and in a BASH shell, use : (colon).
For example, weblogic.jar must be on the classpath. For a complete list, refer to Required Environment and Syntax for weblogic.Server.
In the Classpath field, add the pathname for your class or for a JAR file that contains your class.
For example, you create a startup class named StartBrowser in a package named com.mycompany.startup. You archive the class file in a JAR file named c:\myDomain\src\myJAR.jar. In this case, the Classpath field should contain the following value:
c:\Oracle\Middleware\wlserver_10.3\server\lib\weblogicsp.jar;c:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar;c\myDomain\src\myJAR.jar
step1)Class path can be set using ./setWLSEnv.sh(/wlserver_10.3/server/bin)
step2)Adding a jar file to class path abc.jar to this location(wlserver_10.3/server/lib) and follow step1
If in case you need to set Domain ./setWlEnv.sh(Domain_Home/bin) avil here
I use jrubyc to compile Ruby into class files. One of the Ruby files contains
dat = File.open "data.json", "r"
And there's a "data.json" file alongside. This program runs well if I directly use the jruby command.
After I compiled the Ruby files and put them into a jar, the following error appears when I run java -jar:
Exception in thread "main" org.jruby.exceptions.RaiseException: (Errno::ENOENT) data.json
at org.jruby.RubyFile.initialize(org/jruby/RubyFile.java:334)
at org.jruby.RubyIO.open(org/jruby/RubyIO.java:1144)
at RUBY.(root)(file:/Users/x5lai/Documents/rqrcode.jar!/read.rb:2)
...
To make sure that I have not put data.json in the wrong place, I have copied data.json all over the jar file, but the same error occurs.
Is there anyway to do this? Is JRuby unable to open JSON files once I have compiled the code?
I don't think that it is going to look inside the JAR by default. I created a small test and was able to reproduce your issue. I then did touch data.json and the code no longer had an error. I'm not sure how to specify that you want to look inside the JAR for your data file.
I am attempting to run a groovy script on startup for a web application. I am first trying to follow an example from the book Spring Recipes.
I have a SimpleInterestCalculator in the following package - com.apress.springrecipes.interest
The beans package is in src/test/resources in a package com.wer.com, and that's where the bean is.
My entry in that is
<lang:groovy id="interestCalculator" script-source="classpath:com/apress/springrecipes/interest/SimpleInterestCalculator.groovy">
<lang:property name="rateCalculator" value="rateCalculator" />
</lang:groovy>
I am getting the following error.
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'simpleInterestCalculator':
Could not determine scripted object type for GroovyScriptFactory:
script source locator [classpath:src/com/apress/springrecipes/interest/SimpleInterestCalculator.groovy];
nested exception is java.io.FileNotFoundException:
class path resource [src/com/apress/springrecipes/interest/SimpleInterestCalculator.groovy] cannot be opened because it does not exist
The error you are getting is a FileNotFoundException. This means it is not finding the script file itself. If the file is present, then it may not be on the classpath at runtime.
Check your bin/out directory in your IDE to see if the .groovy file is present there. Sometimes if you have a .groovy in a source directory, your IDE assumes this is 'source' code and compiles it down to bytecode. The result is you would end up with a .class file on the classpath instead of the groovy script itself. This will vary with settings and what IDE you are using. If this seems to be the problem there may be an option for this or you can use an alternate extension that will not be picked up by the compiler.