Setting up xnat on a VM

33 views
Skip to first unread message

Jacob Fosso Tande

unread,
Nov 10, 2021, 1:55:37 PM11/10/21
to xnat_discussion
Greetings,
This is my first on this forum and with xnat. I am trying to set up an experimental xnat
environment. We want to use this for a class and likely research. The experimental
environment will help understand the system before production. I have had some snags
with the prerequisites and will appreciate your help.

My VM has ubuntu 20.04 os
Tomcat9 set up
JAVA-re version 11 is default
PostgresSQL version 12 installed and configured for xnat

After editing tomcat9 default parameter as well as the tomcat9 service,  tomcat9
failed to restart. I did reload the daemond before restarting service. It looks like it
is a permission issue (Am I missing something?). Please see tomcat9 restart log below

============tomcat9 restart log==================

tomcat9.service - Apache Tomcat 9 Web Application Server

     Loaded: loaded (/etc/systemd/system/tomcat9.service; enabled; vendor preset: enabled)

     Active: failed (Result: exit-code) since Wed 2021-11-10 18:22:48 UTC; 1min 45s ago

       Docs: https://tomcat.apache.org/tomcat-9.0-doc/index.html

    Process: 11196 ExecStartPre=/usr/libexec/tomcat9/tomcat-update-policy.sh (code=exited, status=0/SUCCESS)

    Process: 11200 ExecStart=/bin/sh /usr/libexec/tomcat9/tomcat-start.sh (code=exited, status=1/FAILURE)

   Main PID: 11200 (code=exited, status=1/FAILURE


Nov 10 18:22:48 uncg-xnat-lab tomcat9[11200]: WARNING: Permissions incorrect, read permission is not allowed on the file

 +++++++++++++/etc/default/tomcat9

JAVA_OPTS="-Djava.awt.headless=true"

CATALINA_OPTS="-Xms512m -Xmx2g -XX:+UseConcMarkSweepGC -XX:-OmitStackTraceInFastThrow"

CATALINA_OPTS="${CATALINA_OPTS} -Dxnat.home=/data/xnat/home"

++++++++++++++/etc/systemd/system/tomcat9.service

[Unit]

Description=Apache Tomcat 9 Web Application Server

Documentation=https://tomcat.apache.org/tomcat-9.0-doc/index.html

After=network.target

RequiresMountsFor=/var/log/tomcat9 /var/lib/tomcat9


[Service]


# Configuration

Environment="CATALINA_HOME=/usr/share/tomcat9"

Environment="CATALINA_BASE=/var/lib/tomcat9"

Environment="CATALINA_TMPDIR=/tmp"

Environment="JAVA_OPTS=-Djava.awt.headless=true"

# xnat needs this environment

Environment="CATALINA_OPTS=-Xms512m -Xmx2g -XX:+UseConcMarkSweepGC -XX:-OmitStackTraceInFastThrow"

Type=simple

ExecStartPre=+/usr/libexec/tomcat9/tomcat-update-policy.sh

ExecStart=/bin/sh /usr/libexec/tomcat9/tomcat-start.sh

SuccessExitStatus=143

Restart=on-abort

# Security

User=xnat

Group=xnat

PrivateTmp=yes

AmbientCapabilities=CAP_NET_BIND_SERVICE

NoNewPrivileges=true

CacheDirectory=tomcat9

CacheDirectoryMode=750

ProtectSystem=strict

ReadWritePaths=/etc/tomcat9/Catalina/

ReadWritePaths=/var/lib/tomcat9/webapps/

ReadWritePaths=/var/log/tomcat9/

[Install]

WantedBy=multi-user.target

Jacob Fosso Tande

unread,
Nov 11, 2021, 9:31:13 AM11/11/21
to xnat_discussion

I am solving my own issue.
but I think using package manager to install place files in other locations not mentioned. I went through
and checked permissions. I did change the group ownership of all the files in the directory below

sudo chgrp -R xnat /etc/tomcat9/    (files are own by root and group tomcat, reason for change)

I also setup xnat to create directory in tmp the way tomcat (default user would)

Thank you

Herrick, Rick

unread,
Nov 11, 2021, 11:32:18 AM11/11/21
to xnat_di...@googlegroups.com

You need to use Java 8. XNAT won’t run on Java 11 at this time.

 

I’d presume that that is the cause but can’t tell just from the Tomcat service status. You can get a more detailed version of that with this command:

 

journalctl --unit=tomcat9.service

 

You can also get the logs from /var/log/tomcat9, specifically catalina.yyyy-mm-dd.log and localhost.yyyy-mm-dd.log, for example:

 

  • catalina.2021-11-11.log
  • localhost.2021-11-11.log

 

If Java 11 is the problem, one of the first things you’ll see in the localhost log file is something like this:

 

11-Nov-2021 10:26:02.175 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'updateSecurityFilterHandlerMethod' defined in file [/var/lib/tomcat9/webapps/ROOT/WEB-INF/classes/org/nrg/xnat/event/listeners/methods/UpdateSecurityFilterHandlerMethod.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.nrg.xnat.initialization.SecurityConfig': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConfig' defined in file [/var/lib/tomcat9/webapps/ROOT/WEB-INF/classes/org/nrg/xnat/configuration/WebConfig.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.nrg.xnat.configuration.WebConfig$$EnhancerBySpringCGLIB$$18fd9345]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

 

The important bit is that highlighted text: a bunch of APIs that are included in Java 8 are not included in Java 11, including a bunch of the XML APIs. You can work around this with some command-line flags but then you’ll run into other issues. I’ve never been able to get XNAT working with Java 11, even with a lot of tinkering with the configuration.

 

The fix is easy though! First install Java 8:

 

sudo apt --assume-yes install openjdk-8-jdk-headless

 

Then modify /etc/default/tomcat9 to change this line:

 

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

 

To this:

 

JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

 

Now start Tomcat and you should be good to go. Or at least good to go a bit further than you have so far.

 

-- 

Rick Herrick

XNAT Architect/Developer

Computational Imaging Laboratory

Washington University School of Medicine

 

 

From: 'Jacob Fosso Tande' via xnat_discussion <xnat_di...@googlegroups.com>
Date: Wednesday, November 10, 2021 at 12:55 PM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] Setting up xnat on a VM

* External Email - Caution *

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/e85b1fa8-c415-49f7-adf0-b0bf26b443d4n%40googlegroups.com.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

Jacob Fosso Tande

unread,
Nov 11, 2021, 2:09:28 PM11/11/21
to xnat_discussion
Thanks Rick, I will do that

Jacob Fosso Tande

unread,
Nov 11, 2021, 3:22:34 PM11/11/21
to xnat_discussion
Hi Rick,
I did switch to java 8 but still couldn't start xnat. Please se the attached log for detail.
Thank you for your help

On Thursday, November 11, 2021 at 11:32:18 AM UTC-5 Rick Herrick wrote:
catalina.2021-11-11.log

Moore, Charlie

unread,
Nov 11, 2021, 4:49:48 PM11/11/21
to xnat_di...@googlegroups.com
Hi there,

Is /data/xnat/home writable by the tomcat user? The error in that log would seem to imply that it is not if I'm reading it correctly.

Thanks,
Charlie

From: 'Jacob Fosso Tande' via xnat_discussion <xnat_di...@googlegroups.com>
Sent: Thursday, November 11, 2021 2:22 PM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: Re: [XNAT Discussion] Setting up xnat on a VM
 

Jacob Fosso Tande

unread,
Nov 12, 2021, 10:22:02 AM11/12/21
to xnat_discussion

Thanks, yes it is writable to by xnat, tomcat9 user as you can see

ls -la /data/xnat/home/

total 36

drwxr-xr-x  6 xnat xnat 4096 Nov 10 16:44 .

drwxr-xr-x 10 xnat xnat 4096 Nov 10 16:44 ..

-rw-r--r--  1 xnat xnat  220 Feb 25  2020 .bash_logout

-rw-r--r--  1 xnat xnat 3771 Feb 25  2020 .bashrc

-rw-r--r--  1 xnat xnat  807 Feb 25  2020 .profile

drwxr-xr-x  2 xnat xnat 4096 Nov 10 17:14 config

drwxr-xr-x  2 xnat xnat 4096 Nov 12 14:12 logs

drwxr-xr-x  2 xnat xnat 4096 Nov 10 16:44 plugins


I followed the discussion here to give the xnat home rw permission

I added the bold line below to fix the io problem

(Should this be specified in the install document?, clearly xnat generate log files)

sudo emacs /etc/systemd/system/tomcat9.service

# Security

User=xnat

Group=xnat

PrivateTmp=yes

AmbientCapabilities=CAP_NET_BIND_SERVICE

NoNewPrivileges=true

CacheDirectory=tomcat9

CacheDirectoryMode=750

ProtectSystem=strict

ReadWritePaths=/etc/tomcat9/Catalina/

ReadWritePaths=/var/lib/tomcat9/webapps/

ReadWritePaths=/var/log/tomcat9/

# xnat (tomcat user failing to write in xnat home)

ReadWritePaths=/data/xnat/home/

[Install]

WantedBy=multi-user.target

Reply all
Reply to author
Forward
0 new messages