JustNatural
JustNatural

Reputation: 448

JMeter JMS Publisher error when trying to publish to ActiveMQ Artemis queue: java.lang.NoSuchMethodError: javax.jms.Message.setJMSDeliveryTime(J)V

On a Windows 10 machine with Java 11.0.21. I have downloaded a fresh latest version of JMeter 5.6.3.

I have a jmx file with a JMS Publisher Sampler which is configured to connect and publish to a queue running on a remote ActiveMQ Artemis server.

I am using activemq-all-5.18.3.jar in order for the JMS Publisher Sampler to be able to communicate with the remote ActiveMQ Artemis queue.

The activemq-all-5.18.3.jar is placed it in a Dependencies folder on my local path and I load it to the classpath through a config.properties file:

user.classpath=./Dependencies

The config file is invoked like this:

$ jmeter -q .\config.properties -t .\test.jmx

Once the GUI launches, I run the test and get the following error in the JMeter log:

ERROR o.a.j.JMeter: Uncaught exception in thread Thread[Create 1-1,6,main]
java.lang.NoSuchMethodError: javax.jms.Message.setJMSDeliveryTime(J)V
    at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1993) ~[activemq-all-5.18.3.jar:5.18.3]
    at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:329) ~[activemq-all-5.18.3.jar:5.18.3]
    at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:289) ~[activemq-all-5.18.3.jar:5.18.3]
    at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:224) ~[activemq-all-5.18.3.jar:5.18.3]
    at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:298) ~[activemq-all-5.18.3.jar:5.18.3]
    at org.apache.jmeter.protocol.jms.client.Publisher.setPropertiesAndSend(Publisher.java:191) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.client.Publisher.publish(Publisher.java:148) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.sampler.PublisherSampler.sample(PublisherSampler.java:233) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.sampler.BaseJMSSampler.sample(BaseJMSSampler.java:98) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) ~[ApacheJMeter_core.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) ~[ApacheJMeter_core.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.6.3]
    at java.base/java.lang.Thread.run(Thread.java:834) [?:?]

I want to be able to Publish the message using the JMS Publisher sampler.

I've tried changing the jar dependency version to a the current latest one (activemq-all-6.1.0.jar) and got a different error:

java.lang.UnsupportedClassVersionError: org/apache/activemq/jndi/ActiveMQInitialContextFactory has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[?:?]
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[?:?]
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555) ~[?:?]
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458) ~[?:?]
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452) ~[?:?]
    at java.base/java.security.AccessController.doPrivileged(Native Method) ~[?:?]
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451) ~[?:?]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
    at java.base/java.lang.Class.forName0(Native Method) ~[?:?]
    at java.base/java.lang.Class.forName(Class.java:398) ~[?:?]
    at java.naming/com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:127) ~[?:?]
    at java.naming/com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:133) ~[?:?]
    at java.naming/com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:100) ~[?:?]
    at java.naming/javax.naming.spi.NamingManager.getFactory(NamingManager.java:757) ~[?:?]
    at java.naming/javax.naming.spi.NamingManager.lambda$getInitialContext$1(NamingManager.java:722) ~[?:?]
    at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329) ~[?:?]
    at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205) ~[?:?]
    at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:722) ~[?:?]
    at java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305) ~[?:?]
    at java.naming/javax.naming.InitialContext.init(InitialContext.java:236) ~[?:?]
    at java.naming/javax.naming.InitialContext.<init>(InitialContext.java:208) ~[?:?]
    at org.apache.jmeter.protocol.jms.client.InitialContextFactory.lookupContext(InitialContextFactory.java:66) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.client.InitialContextFactory.getContext(InitialContextFactory.java:155) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.client.Publisher.<init>(Publisher.java:126) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.sampler.PublisherSampler.initClient(PublisherSampler.java:185) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.sampler.PublisherSampler.sample(PublisherSampler.java:209) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.protocol.jms.sampler.BaseJMSSampler.sample(BaseJMSSampler.java:98) ~[ApacheJMeter_jms.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) ~[ApacheJMeter_core.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) ~[ApacheJMeter_core.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.6.3]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.6.3]
    at java.base/java.lang.Thread.run(Thread.java:834) [?:?]

Does anyone have any idea what the cause is and how I could fix it?

Upvotes: 0

Views: 289

Answers (1)

Justin Bertram
Justin Bertram

Reputation: 35123

You're using the OpenWire JMS client that ships with ActiveMQ Classic. Version 5.18.3 doesn't support the JMS 2 method javax.jms.Message.setJMSDeliveryTime() which is why you're hitting the NoSuchMethodError. Version 6.0.1 requires Java 17 or higher which is why you're hitting the UnsupportedClassVersionError.

I recommend you use the Core JMS client that ships with ActiveMQ Artemis. It fully supports JMS 2 and doesn't require Java 17. It only requires Java 11. If you're downloading it and dropping it into the JMeter classpath I recommend this one.

Upvotes: 4

Related Questions