I have followed the online documentation on the xnat site (https://wiki.xnat.org/documentation/getting-started-with-xnat/xnat-installation-guide) and installed apache tomcat 9 ( version 9.0.75, JVM Version : 1.8.0_372_b07, JVM Vendor: Temurin). But when I click 'start' on the xnat webapp, I get the error:
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]]
The log file shows the following (truncated to allow it to post here):
... 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)
According to 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.
I am wondering if the issue is either in the unit file or in the postgresql config (TCP/IP connections) setup. I am only using tomcat on localhost. In my pg_hba.conf file i have just added the line listen_addresses = '*'
If you look at the unit file below, I have given it multiple folders to readwrite. Tomcat is by default using /opt/tomcat. But the xnat documentation settings indicate I use /var/lib/tomcat, /var/log/tomcat, and /etc/tomcat/Catalina as ReadWritePaths. I have just added all those alongwith my installation default paths in my unit file. I am wondering if that's where the error is.
My tomcat unit file is :
[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
The context.xml file under /opt/tomcat/webapps/xnat-1.8.8/META-INF is:
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>
I have since also unsuccessfully tried to deploy xnat via vagrant and docker. I will be grateful for any help you can give me.