activemq启动报错:Unsupported major.minor version 52.0

使用的activemq版本是 5.15.13, 本来在 JDK 1.8版本下应该正常运行,手动启动没问题,使用crontab脚本检测启动时发现JDK版本不对。

INFO: Loading '/software/apache-activemq-5.15.13//bin/env'
INFO: Using java '/usr/bin/java'
INFO: Loading '/software/apache-activemq-5.15.13//bin/env'
INFO: Using java '/usr/bin/java'
INFO: Waiting at least 30 seconds for regular process termination of pid '168419' : 
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/activemq/console/Main : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:442)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

查看日志发现其使用的 /usr/bin/java

# /usr/bin/java -version
java version "1.7.0_141"
OpenJDK Runtime Environment (rhel-2.6.10.5.el7-x86_64 u141-b02)
OpenJDK 64-Bit Server VM (build 24.141-b02, mixed mode)

# ll /usr/bin/java
lrwxrwxrwx. 1 root root 22 Jul 23 17:59 /usr/bin/java -> /etc/alternatives/java

知道了原因,于是修改软连接指向我们自己的JDK:

# ln -snf /software/server/jdk-1.8.0_211/bin/java /usr/bin/java

这种情况出现在有多个版本的JDK,却没有同步的情况。

你可能感兴趣的:(Java)