Uploaded image for project: 'XWiki Docker images'
  1. XWiki Docker images
  2. XDOCKER-427

XWiki is deployed twice when CONTEXT_PATH is set to something other than ROOT

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • None
    • Unknown
    • N/A
    • N/A

    Description

      Reported on the forum: https://forum.xwiki.org/t/xwiki-deploying-twice-when-context-path-variable-is-set-up/18732

      Problem

      When the CONTEXT_PATH environment variable is set to anything other than ROOT, the container starts two XWiki webapps in the same Tomcat JVM. The second one to start fails with The 'org.xwiki.infinispan' JMX domain is already in use and the log then fills up with hundreds of those errors. Browsing the root URL returns a 404 and only http://localhost:8080/<CONTEXT_PATH> works.

      Steps to reproduce

      1. Go to 18.4/postgres-tomcat.
      2. Add CONTEXT_PATH: wiki to the environment of the web service in docker-compose.yml.
      3. Run docker compose up.

      Cause

      configure() in xwiki/docker-entrypoint.sh deploys a non-ROOT context like this:

      mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH
      cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/
      

      This used to be a mv and was changed to a merging copy in XDOCKER-402, so that a config file bind-mounted into the target context directory (e.g. a custom logback.xml) is not clobbered: mv cannot merge into an already existing directory, and Docker creates that directory before the entrypoint runs when such a mount is declared.

      The copy itself is fine, but nothing removes /usr/local/tomcat/webapps/ROOT afterwards and Tomcat auto-deploys every directory under webapps/. So both ROOT and the configured context get deployed as full XWiki webapps in the same JVM, and the loser of the race dies on the Infinispan JMX domain.

      Affected versions

      All images generated after the XDOCKER-402 change (19 March 2026): 18.2.0 and later, 17.10.6 and later, all 18.4.x, and 16.10.18 and later. Before that, mv left nothing behind in ROOT so only one webapp was deployed.

      Verification

      Reproduced on the published xwiki:18.4.0-postgres-tomcat image with CONTEXT_PATH=wiki: Tomcat deploys both webapps/wiki and webapps/ROOT, and the log contains 284 Infinispan JMX errors. Adding rm -rf /usr/local/tomcat/webapps/ROOT after the copy makes it deploy wiki only, with zero such errors.

      Note about multi-level context paths

      The multi-level context path support added by the same change does not work either: Tomcat only deploys the immediate children of webapps/, so CONTEXT_PATH=foo/bar creates webapps/foo/bar and Tomcat deploys an empty webapp at /foo, never at /foo/bar. Tomcat's convention for a multi-level path is a foo#bar directory name.

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: