- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我对 vagrant 不是很熟悉,我有一个 Ubuntu 16.04 的图像,其中包含一个可以设置和运行 tomcat8 服务器应用程序的脚本。我去一台windows主机上设置,每次tomcat服务都启动失败。
运行ansible playbook的结果是:
TASK [Restart tomcat] **********************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "service tomcat8 restart", "delta": "0:00:00.046020", "end": "2019-02-02 17:55:28.417905", "failed": true, "rc": 1, "start": "2019-02-02 17:55:28.371885", "stderr": "Job for tomcat8.service failed because the control process exited with error code. See \"systemctl status tomcat8.service\" and \"journalctl -xe\" for details.", "stdout": "", "stdout_lines": [], "warnings": ["Consider using service module rather than running service"]}
尝试运行 sudo service tomcat8 restart
的结果是:
Job for tomcat8.service failed because the control process exited with error code. See "systemctl status tomcat8.service" and "journalctl -xe" for details.
通过 sudo service tomcat8 status
检查服务状态给出:
● tomcat8.service - LSB: Start Tomcat.
Loaded: loaded (/etc/init.d/tomcat8; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-02-04 16:15:19 UTC; 46s ago
Docs: man:systemd-sysv-generator(8)
Process: 10703 ExecStop=/etc/init.d/tomcat8 stop (code=exited, status=0/SUCCESS)
Process: 11859 ExecStart=/etc/init.d/tomcat8 start (code=exited, status=127)
Feb 04 16:15:19 vagrant systemd[1]: Starting LSB: Start Tomcat....
Feb 04 16:15:19 vagrant tomcat8[11859]: [58B blob data]
Feb 04 16:15:19 vagrant systemd[1]: tomcat8.service: Control process exited, code=exited status=127
Feb 04 16:15:19 vagrant systemd[1]: Failed to start LSB: Start Tomcat..
Feb 04 16:15:19 vagrant systemd[1]: tomcat8.service: Unit entered failed state.
Feb 04 16:15:19 vagrant systemd[1]: tomcat8.service: Failed with result 'exit-code'.
我曾尝试使用 apt-get 重新安装 tomcat8,这会导致 prerm 和 postinst 出现错误,因此我删除了所有 tomcat8.prerm、tomcat8.preinst、tomcat8.postinst 等文件并再次尝试,但没有成功. (老实说不记得那个的确切结果 - 如果需要我可以再试一次并更新这篇文章)
我还尝试在运行 ansible playbook 之前手动安装 tomcat8,结果发生了同样的事情。
我只是觉得我一直在胡乱尝试,并不确定真正从哪里开始深入挖掘,所以非常感谢任何和所有想法。
更新:事实证明,当它在 macOS 主机上运行时,不会发生此错误..
更新第 2 部分:我在剧本中找到了问题 child :
- name: Configure tomcat memory
template:
src: /home/vagrant/shared/resources/tomcat8
dest: /etc/default/tomcat8
mode: 0640
force: True
如果我从剧本中删除它,则不会发生此错误。我不认为它与 tomcat8 文件的内容有关,因为我尝试基本上注释掉所有行以返回默认值但仍然有问题。我猜这可能与权限有关?尽管如此,它正在复制的文件中包含以下内容:
# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat8.
TOMCAT8_USER=tomcat8
# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat8.
TOMCAT8_GROUP=tomcat8
# The home directory of the Java development kit (JDK). You need at least
# JDK version 7. If JAVA_HOME is not set, some common directories for
# OpenJDK and the Oracle JDK are tried.
#JAVA_HOME=/usr/lib/jvm/java-7-openjdk
# You may pass JVM startup parameters to Java here. If unset, the default
# options will be: -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC
#
# Use "-XX:+UseConcMarkSweepGC" to enable the CMS garbage collector (improved
# response time). If you use that option and you run Tomcat on a machine with
# exactly one CPU chip that contains one or two cores, you should also add
# the "-XX:+CMSIncrementalMode" option.
#JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC" # original setting
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -Dapp.profile=vm"
# To enable remote debugging uncomment the following line.
# You will then be able to use a java debugger on port 8000.
JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
# Java compiler to use for translating JavaServer Pages (JSPs). You can use all
# compilers that are accepted by Ant's build.compiler property.
#JSP_COMPILER=javac
# Use the Java security manager? (yes/no, default: no)
#TOMCAT8_SECURITY=no
# Number of days to keep logfiles in /var/log/tomcat8. Default is 14 days.
#LOGFILE_DAYS=14
# Whether to compress logfiles older than today's
#LOGFILE_COMPRESS=1
# Location of the JVM temporary directory
# WARNING: This directory will be destroyed and recreated at every startup !
#JVM_TMP=/tmp/tomcat8-temp
# If you run Tomcat on port numbers that are all higher than 1023, then you
# do not need authbind. It is used for binding Tomcat to lower port numbers.
# (yes/no, default: no)
#AUTHBIND=no
#GEOSERVER_DATA_DIR=/efs/geoserver_data
最佳答案
问题很可能是 systemd 模块中的错误 JAVA_HOME 路径。检查/etc/systemd/system/tomcat.service 中的 JAVA_HOME 路径,它的末尾不应有“jre/”,这对于较新的 Java 版本是错误的。尝试:
sudo nano /etc/systemd/system/tomcat.service
并删除 JAVA_HOME 路径尾随的“jre/”。然后重启tomcat
sudo systemctl daemon-reload
sudo systemctl restart tomcat
关于windows - Tomcat8 无法在 Windows 主机上的 VirtualBox Vagrant 中的 Ubuntu 16.04 中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54520246/
我是一名优秀的程序员,十分优秀!