centos7 activemq启动失败的解决过程

Posted on 2024-03-24 21:47  fatrabit  阅读(363)  评论(0编辑  收藏  举报

时隔很久重新启动虚拟机中的centos7,准备启用activemq。运行命令如下:

      $./activemq start
INFO: Loading '/home/****/apache-activemq-5.18.1//bin/env'
INFO: Using java '/usr/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/home/****/apache-activemq-5.18.1//data/activemq.pid' (pid '10539')

虽然看似启动成功,也出现了pid。实际上启动失败,端口均未启动,使用activemq status命令查看,反馈未启动。采用关闭防火墙等等一系列方法,均无效。后使用以下命令

./activemq console
INFO: Loading '/home/*****/apache-activemq-5.18.1//bin/env'
INFO: Using java '/usr/bin/java'
INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C)
INFO: Creating pidfile /home/******/apache-activemq-5.18.1//data/activemq.pid
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/activemq/console/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

可以看到红色提示的两行信息。提示JRE版本不够。查询activemq官网,5.18.1版本应该与5.18.3类似,需要Java 11及以上版本,如下图所示。

 二、解决步骤

1、下载并安装java11

从oracle官网下载

2、解压到指定目录

tar -zxvf jdk-11_linux-x64_bin.tar.gz -C /opt/

3.配置环境

在/etc/profile文件末尾添加如下内容,配置JAVA11的环境变量:

export JAVA_HOME=/opt/jdk-11.0.22
export PATH=$JAVA_HOME/bin:$PATH

修改完之后,过程如下:

[root@192 etc]# source /etc/profile
[root@192 etc]# java -version
java version "11.0.22" 2024-01-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.22+9-LTS-219)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.22+9-LTS-219, mixed mode)

4.完成后使用普通账户启动仍未成功

5.之后采用升级java的方法,并将profile中的两条注释并刷新

yum install java-1.8.0-openjdk

6.更新完毕使用root账号启动成功,使用普通账户启动仍然失败,查看java版本为11。

7.重启centos7,使用普通账户启动失败,java版本为8。重新启用profile中新添的两条,java为11。启动成功。

 

问题解决,但是不彻底。

 

Copyright © 2025 fatrabit
Powered by .NET 9.0 on Kubernetes