Active MQ - HelloWorld example exception

2019-06-20 01:34发布

I'm trying to run the hello world example found here

I added activemq-all-5.5.1.jar to the libraries already

It builds successfully with the following warning

warning: [options] bootstrap class path not set in conjunction with -source 1.6

But it doesn't run, I get this exception

Exception in thread "Thread-0" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/jms/JMSException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at hw_testing.HW_testing$HelloWorldProducer.run(HW_testing.java:69) at java.lang.Thread.run(Thread.java:722)

Exception in thread "Thread-1" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/jms/JMSException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at hw_testing.HW_testing$HelloWorldProducer.run(HW_testing.java:69) at java.lang.Thread.run(Thread.java:722)

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

Can anybody help me with that please?

1条回答
冷血范
2楼-- · 2019-06-20 02:04

This is a problem with dependencies (javax/jms/JMSException is in multiple jars), which occurs e.g. with javaee-api (5 or 6) - this jar lacks 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 classpath, you will get the java.lang.ClassFormatError.

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

查看更多
登录 后发表回答