Active MQ - HelloWorld example exception

I am trying to run the hello world example found here

I added activeemq-all-5.5.1.jar to existing libraries

It works successfully with the following warning

warning: [options] path to bootstrap not installed with -source 1.6

But it does not start, I get this exception

Exception in thread "Thread-0" java.lang.ClassFormatError: There is no code attribute in a method that is not native or abstract in the javax / jms / JMSException class file in java.lang.ClassLoader.defineClass1 (native method) in java.lang .ClassLoader.defineClass (ClassLoader.java:791) in java.security.SecureClassLoader.defineClass (SecureClassLoader.java:142) on java.net.URLClassLoader.defineClass (URLClassLoader.java:449) on java.net.URLClassLoader $ (URLClassLoader.java:71) on java.net.URLClassLoader $ 1.run (URLClassLoader.javahaps61) on java.net.URLClassLoader $ 1.run (URLClassLoader.javahaps55) in java.security.AccessController.doPrivileged (native method ) on java.net.URLClassLoader.findClass (URLClassLoader.javahaps54) in java.lang.ClassLoader.loadClass (ClassLoader.java:423) at sun.misc.Launcher $ App ClassLoader.loadClass (Launcher.java:308) in java.lang.ClassLoader.loadClass (ClassLoader.javahaps56) at hw_testing.HW_testing $ HelloWorldProducer.run (HW_testing.java:69) in java.lang.Thread.run (Thread .java: 722)

Exception in thread "Thread-1" java.lang.ClassFormatError: There is no code attribute in a method that is not native or abstract in the javax / jms / JMSException class file in java.lang.ClassLoader.defineClass1 (native method) in java.lang .ClassLoader.defineClass (ClassLoader.java:791) in java.security.SecureClassLoader.defineClass (SecureClassLoader.java:142) on java.net.URLClassLoader.defineClass (URLClassLoader.java:449) on java.net.URLClassLoader $ (URLClassLoader.java:71) on java.net.URLClassLoader $ 1.run (URLClassLoader.javahaps61) on java.net.URLClassLoader $ 1.run (URLClassLoader.javahaps55) in java.security.AccessController.doPrivileged (native method ) on java.net.URLClassLoader.findClass (URLClassLoader.javahaps54) in java.lang.ClassLoader.loadClass (ClassLoader.java:423) at sun.misc.Launcher $ App ClassLoader.loadClass (Launcher.java:308) in java.lang.ClassLoader.loadClass (ClassLoader.javahaps56) at hw_testing.HW_testing $ HelloWorldProducer.run (HW_testing.java:69) in java.lang.Thread.run (Thread .java: 722)

... And the same exception for threads 3 and 4

Can anyone help me with this?

+6
source share
1 answer

This is a dependency problem ( javax/jms/JMSException is in several jars), which happens, for example. with javaee-api (5 or 6) - this bank does not have some method bodies for several classes. activemq-all-5.5.1.jar also contains javax.jms.JMSException , but these classes are not identical. If javaee-api comes first in the classpath, you will get java.lang.ClassFormatError .

If you are using maven, put javaee-api after activemq-all (or remove it). In general, remove unnecessary dependencies.

+11
source

Source: https://habr.com/ru/post/902052/


All Articles