我已按照xnat网站上的在线文档(https://wiki.xnat.org/documentation/getting-started-with-xnat/xnat-i nstallation-guide)并安装了apache tomcat 9(版本9.0.75,JVM版本) :1.8.0_372_b07,JVM 供应商:Temurin)。但是当我在 xnat web 应用程序上单击“开始”时,出现错误:
FAIL - Application at context path [/xnat-web-1.8.8] could not be started
FAIL - Encountered exception [org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35a50a4c]]
Run Code Online (Sandbox Code Playgroud)
日志文件显示以下内容(被截断以允许在此处发布):
... org.apache.catalina.core.ApplicationContext.log HTMLManager: Error starting [/xnat-web-1.8.8]
org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@6dde5c8c]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
...
...
...
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.NullPointerException
at java.lang.String.startsWith(String.java:1405)
at java.lang.String.startsWith(String.java:1434)
at org.apache.catalina.webresources.AbstractFileResourceSet.file(AbstractFileResourceSet.java:98)
at org.apache.catalina.webresources.DirResourceSet.getResource(DirResourceSet.java:94)
at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:272)
at org.apache.catalina.webresources.Cache.getResource(Cache.java:64)
at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:211)
at org.apache.catalina.webresources.StandardRoot.listResources(StandardRoot.java:347)
at org.apache.catalina.webresources.StandardRoot.processWebInfLib(StandardRoot.java:585)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:722)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
Run Code Online (Sandbox Code Playgroud)
根据 ChatGPT 的说法:
Based on the provided log file, it appears that there is an error during the deployment of the web application '/xnat-web-1.8.8' in Tomcat. The error message indicates a NullPointerException and a LifecycleException related to the StandardRoot component.
The root cause of the issue seems to be the NullPointerException occurring within the AbstractFileResourceSet class. It specifically fails when attempting to access a file resource, likely due to a missing or invalid file path.
Run Code Online (Sandbox Code Playgroud)
我想知道问题是否出在单元文件中或 postgresql 配置(TCP/IP 连接)设置中。我只在本地主机上使用 tomcat。在我的 pg_hba.conf 文件中,我刚刚添加了这一行listen_addresses = '*'
如果您查看下面的单元文件,我已为其提供了多个文件夹以供读写。Tomcat 默认使用 /opt/tomcat。但 xnat 文档设置表明我使用 /var/lib/tomcat、/var/log/tomcat 和 /etc/tomcat/Catalina 作为 ReadWritePaths。我刚刚在我的单元文件中添加了所有这些以及我的安装默认路径。我想知道这是否是错误所在。我的 tomcat 单元文件是:
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
User=xnat
Group=xnat
PrivateTmp=yes
Environment="JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS="-Xms512M -Xmx1024M -server -XX:+UseParallelGC -Dxnat.home=/data/xnat/home"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
#AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
CacheDirectory=tomcat
CacheDirectoryMode=750
#ProtectSystem=strict
ReadWritePaths=/etc/tomcat/Catalina/
ReadWritePaths=/opt/tomcat/webapps/
ReadWritePaths=/var/lib/tomcat/webapps/
ReadWritePaths=/opt/log/tomcat/
ReadWritePaths=/var/log/tomcat/
ReadWritePaths=/data/xnat/home
ReadWritePaths=/home/xnat/
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
/opt/tomcat/webapps/xnat-1.8.8/META-INF 下的 context.xml 文件为:
xml version="1.0" encoding="utf-8"?>
<!--
~ web: context.xml
~ XNAT http://www.xnat.org
~ Copyright (c) 2005-2021, Washington University School of Medicine and Howard Hughes Medical Institute
~ All Rights Reserved
~
~ Released under the Simplified BSD.
-->
<Context>
<!--
For Tomcat 7 compatibility, uncomment the <Loader> element and comment out the <Resources>
and <CookieProcessor> elements under that.
-->
<!-- Loader className="org.apache.catalina.loader.VirtualWebappLoader" searchVirtualFirst="true" virtualClasspath="${xnat.home}/plugins/*.jar"/ -->
<!--
For Tomcat 8 compatibility, uncomment the <Resources> and <CookieProcessor> elements below and
comment out the <Loader> element below that.
-->
<Resources>
<PreResources className="org.apache.catalina.webresources.DirResourceSet" base="${xnat.home}/plugins" webAppMount="/WEB-INF/lib" />
</Resources>
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
<JarScanner scanAllDirectories="true" />
<Parameter name="xnatHome" value="${xnat.home}"/>
<Manager pathname="" />
</Context>
Run Code Online (Sandbox Code Playgroud)
此后我也尝试通过 vagrant 和 docker 部署 xnat,但没有成功。我将非常感谢您能给我的任何帮助。
在我看来,问题与 Tomcat 无法正确处理文件中定义的应用程序资源有关context.xml:
<Resources>
<PreResources className="org.apache.catalina.webresources.DirResourceSet" base="${xnat.home}/plugins" webAppMount="/WEB-INF/lib" />
</Resources>
Run Code Online (Sandbox Code Playgroud)
其原因很可能是${xnat.home}占位符未成功解析,可能是因为未正确定义同名的系统属性。
您在定义环境变量时尝试在单元文件中定义该系统属性CATALINA_OPTS:
Environment="CATALINA_OPTS="-Xms512M -Xmx1024M -server -XX:+UseParallelGC -Dxnat.home=/data/xnat/home"
Run Code Online (Sandbox Code Playgroud)
请注意,它的定义不正确,请注意"后面的CATALINA_OPTS=。
它应该是:
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC -Dxnat.home=/data/xnat/home"
Run Code Online (Sandbox Code Playgroud)
这可能是一个错字,但也可以解释问题。
| 归档时间: |
|
| 查看次数: |
248 次 |
| 最近记录: |