添加tomcat开机启动服务时报错:Neither the JAVA_HOME nor the JRE_HOME enviromment variable is defined
首先,参考的 https://blog.csdn.net/wabil/article/details/78818249 的方式添加 tomcat 开机启动,这种方式不需要添加 setenv.sh 文件,轻量级,非常方便,具体方式如下:
1. 创建一个服务文件
vim /lib/systemd/system/tomcat.service 复制如下内容,修改后保存:
[Unit]
Description=tomcat
After=network.target [Service]
Type=oneshot
ExecStart=/home/apache-tomcat-7.0.70/bin/startup.sh // 自已的tomcat目录
ExecStop=/home/apache-tomcat-7.0.70/bin/shutdown.sh // 自已的tomcat目录
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes [Install]
WantedBy=multi-user.target
2. 启动服务
systemctl start tomcat.service
执行这步的时候,始终报启动失败,执行下面步骤查看失败原因。
3. 查看服务状态
systemctl status tomcat.service
没理由 JAVA_HOME 和 JRE_HOME 不存在啊,明明是存在的,检查一下发现确实是存在的:
解决方法:
方法1. 在 tomcat/bin/setclasspath.sh 中添加 JAVA_HOME 和 JRE_HOME 的指向(试了一下,不知道什么原因没搞成功)
# -----------------------------------------------------------------------------
# Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
# are valid and consistent with the selected start-up options and set up the
# endorsed directory.
# -----------------------------------------------------------------------------
#
24 # JAVA_HOME=/usr/java/jdk1.8.0_171
25 # JRE_HOME=/usr/java/jdk1.8.0_171/jre
方法2. 在 tomcat.service 中添加 JAVA_HOME 和 JRE_HOME 的指向(推荐)
Environment='JAVA_HOME=/usr/java/jdk1.8.0_171'
Environment='JRE_HOME=/usr/java/jdk1.8.0_171/jre'
此时再次执行服务启动命令 systemctl start tomcat.service 成功,服务运行状态如下:
附完整的 tomcat.service 文件
[Unit]
Description=Tomcat
After=network.target [Service]
Type=forking
Environment='JAVA_HOME=/usr/java/jdk1.8.0_171'
Environment='JRE_HOME=/usr/java/jdk1.8.0_171/jre'
ExecStart=/opt/my/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/opt/my/tomcat/shutdown.sh
RemainAfterExit=yes [Install]
WantedBy=multi-user.target
4. 设置为开机启动
systemctl enable tomcat.service
添加tomcat开机启动服务时报错:Neither the JAVA_HOME nor the JRE_HOME enviromment variable is defined的更多相关文章
- 普通用户操作tomcat项目时报:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program
在使用普通用户更新tomcat项目适合出现这个信息,Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At ...
- python paramiko ssh.exec_command()启动tomcat服务器应用进程失败问题解决方法- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this progr
问题说明:
- Tomcat9+JDK 13报错Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program
Tomcat使用的是https://tomcat.apache.org/download-90.cgi Tomcat9 之前安装的JDK 13,有JAVA_HOME环境变量地址(C:\Program ...
- 启动tomcat 报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
[root@localhost META-INF]# systemctl start tomcat Job for tomcat.service failed because the control ...
- tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable
linux 下 启动tomcat 报: Neither the JAVA_HOME nor the JRE_HOME environment variable is definedAt least o ...
- tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
windows系统: 部署了一个Tomcat8.5.15,bin目录下startup.bat执行,结果提示Neither the JAVA_HOME nor the JRE_HOME enviro ...
- Jenkins启动Tomcat时提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
Jenkins构建提示: [SSH] executing...Neither the JAVA_HOME nor the JRE_HOME environment variable is defi ...
- linux安装tomcat Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
这两天我们的开发机重启了好几次,发现每次重启后我的tomcat总是没有启动.检查java路径,配置正确,后来拿普通账号启动tomcat时报如下的错: Neither the JAVA_HOME nor ...
- Java项目启动时候报Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 解决办法
今天在发布Java项目的时候又遇到 Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At leas ...
随机推荐
- codeforces 362B
#include<stdio.h> #include<stdlib.h> int cmp(const void *a,const void *b) { return *(int ...
- android开发里跳过的坑——onActivityResult在启动另一个activity的时候马上回调
该问题是由于被启动的activity的launchMode为singleTask模式,该模式下不可以使用onActivityResult,要使用onActivityResult,被启动的activit ...
- windows开启远程
windows开启远程桌面超级简单,跟linux相比太简单了. 补充:有瑕疵,应该是远程中的远程桌面属性打钩,但是W8.1没有这个选项,W7可以,其次创建一个管理员账户,身份是管理员,不是标准用户,要 ...
- struts面试题及答案【重要】
1. 简述 Struts2 的工作流程: ①. 请求发送给 StrutsPrepareAndExecuteFilter ②. StrutsPrepareAndExecuteFilter 判定该请求是否 ...
- 网易2018校招 合唱 DP
时间限制:2秒 空间限制:131072K 小Q和牛博士合唱一首歌曲,这首歌曲由n个音调组成,每个音调由一个正整数表示.对于每个音调要么由小Q演唱要么由牛博士演唱,对于一系列音调演唱的难度等于所有相 ...
- JDBC实例代码
以下内容引用自http://wiki.jikexueyuan.com/project/jdbc/sample-code.html: 前提: 1.在MySQL中创建数据表和增加模拟数据: DROP TA ...
- 基于图片识别服务的IOS图片识别程序
由于TensorFlow提供的IOS版Demo相对于Android版识别率不高,所以开发了通过识别服务进行图片识别的IOS版程序. 该程序基于图片识别服务(http://www.cnblogs.com ...
- linux 虚拟网卡
linux中可以通过一个物理网卡,模拟出多个虚拟网卡,并在网卡中配置ip. 下面做一个实验. 实验描述: 我们有server A (ip 10.79.148.205),server B (10.79. ...
- java IO流之三 使用缓冲流来读写文件
原文:http://blog.csdn.net/haluoluo211/article/details/52183219 一.通过BufferedReader和BufferedWriter来读写文件 ...
- 原则 principles
1.找到对的人来讨论问题. 2.把工作分配给对的人才能把事情做对. 3.