Reputation: 11
I have a Java project that includes dependencies on other maven projects including rest-assured (4.1.2). This has a dependency on groovy (2.5.8). I need to use functionality from this project in JMeter, so I dropped the jar for that project into the lib directory for JMeter. When I run JMeter, however, it's unable to load the JSR223 Sampler. In the log, there's an error due to a dependency conflict. JMeter is expecting groovy 3.0.11 but instead is finding groovy 2.5.8 due to my custom jar. If I upgrade rest-assured to the latest, then my custom jar is including groovy 4.0.6.
Any suggestions on how to resolve the conflict? Can I tell JMeter to use a newer version of groovy?
2023-02-24 13:21:21,009 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[AWT-EventQueue-0,6,main]
java.lang.ExceptionInInitializerError: null
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:206) ~[?:?]
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:195) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineFactory.getLanguageVersion(GroovyScriptEngineFactory.java:95) ~[groovy-jsr223-3.0.11.jar:3.0.11]
at org.apache.jmeter.util.JSR223BeanInfoSupport.<clinit>(JSR223BeanInfoSupport.java:69) ~[ApacheJMeter_core.jar:5.5]
at java.lang.J9VMInternals.newInstanceImpl(Native Method) ~[?:?]
at java.lang.Class.newInstance(Class.java:2338) ~[?:?]
at com.sun.beans.finder.InstanceFinder.instantiate(InstanceFinder.java:98) ~[?:?]
at com.sun.beans.finder.InstanceFinder.find(InstanceFinder.java:66) ~[?:?]
at com.sun.beans.finder.BeanInfoFinder.find(BeanInfoFinder.java:41) ~[?:?]
at java.beans.Introspector.findExplicitBeanInfo(Introspector.java:467) ~[?:?]
at java.beans.Introspector.<init>(Introspector.java:417) ~[?:?]
at java.beans.Introspector.getBeanInfo(Introspector.java:195) ~[?:?]
at org.apache.jmeter.testbeans.gui.TestBeanGUI.<init>(TestBeanGUI.java:162) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.GuiPackage.getGuiFromCache(GuiPackage.java:417) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.GuiPackage.getGui(GuiPackage.java:266) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.GuiPackage.getGui(GuiPackage.java:237) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.tree.JMeterTreeModel.addComponent(JMeterTreeModel.java:160) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:131) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:131) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:131) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:123) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.GuiPackage.addSubTree(GuiPackage.java:554) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:199) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:130) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:101) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.action.LoadRecentProject.doActionAfterCheck(LoadRecentProject.java:71) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest.doAction(AbstractActionWithNoRunningTest.java:44) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:87) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.gui.action.ActionRouter.lambda$actionPerformed$0(ActionRouter.java:69) ~[ApacheJMeter_core.jar:5.5]
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) ~[?:?]
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) ~[?:?]
at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?]
at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?]
at java.security.AccessController.doPrivileged(AccessController.java:717) ~[?:?]
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) ~[?:?]
at java.awt.EventQueue.dispatchEvent(EventQueue.java:740) ~[?:?]
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) ~[?:?]
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) ~[?:?]
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) ~[?:?]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) ~[?:?]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) ~[?:?]
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) ~[?:?]
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-xml is loaded in version 4.0.6 and you are trying to load version 3.0.11
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$DefaultModuleListener.onModule(MetaClassRegistryImpl.java:534) ~[custom-framework-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
Upvotes: 0
Views: 773
Reputation: 11
So I was able to resolve it through my java project by excluding groovy from the rest-assured dependency and adding the groovy dependency with same version as JMeter. That works.
For example:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.5.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/io.rest-assured/json-path -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>3.0.11</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>3.0.11</version>
</dependency>
Upvotes: 0
Reputation: 168002
Classic Jar Hell, you need to ensure to have the same .jar versions of a library in your project classpath.
You can try using i.e. RestAssured 4.5.0 which depends on Groovy 3.0.9, my expectation is that you shouldn't have any problems with this.
If you cannot amend your project dependencies you can remove Groovy from JMeter completely by deleting groovy*
jars from the "lib" directory of your JMeter installation and use Java Request or JUnit Request samplers or create your custom JMeter plugin invoking your project code in JMeter script.
Upvotes: 0