Modifying XNAT for Tomcat 8

The default XNAT war package is built to work with Tomcat 7, but you can easily modify the application to work with Tomcat 8 if required:

  1. Download the latest version of the XNAT application.

  2. Extract the file META-INF/context.xml (this requires having the Java JDK available on your path):

    $ jar xf xnat-web-1.7.5.3.war META-INF/context.xml


    This file should look something like this (edited for clarity):

    <?xml version="1.0" encoding="utf-8"?>
    <Context>
        <Loader className="org.apache.catalina.loader.VirtualWebappLoader" searchVirtualFirst="true" virtualClasspath="${xnat.home}/plugins/*.jar"/>
        <JarScanner scanAllDirectories="true" />
        <Parameter name="xnatHome" value="${xnat.home}"/>
        <Manager pathname="" />
    </Context>
  3. EditMETA-INF/context.xml and delete the line with the <Loader> element.

  4. Add the following lines to the file right after the <Context> element:

    <Resources>
        <PostResources className="org.apache.catalina.webresources.DirResourceSet" base="${xnat.home}/plugins" webAppMount="/WEB-INF/lib" />
    </Resources>
    <CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
  5. Save the file and close your editor.

  6. Update the war file with your modified META-INF/context.xml file:

    $ jar uf xnat-web-1.7.5.3.war META-INF/context.xml
  7. Continue with your deployment/installation using the updated war file in place of the standard XNAT application.


The standard release of XNAT already has the lines required for Tomcat 8 compatibility, but they're commented out. Delete the <Loader> element then delete the "!--" string at the beginning of the <Resources> element and the "--" string at the end of the <CookieProcessor> element.

The final version of your modified configuration file should look something like this:

<?xml version="1.0" encoding="utf-8"?>
<Context>
    <Resources>
        <PostResources 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>


$label.name