This issue has been created
There are 2 updates, 1 comment.
 
 
XWiki Docker images / cid:jira-generated-image-avatar-3f874493-3d3f-4d2c-8aee-9d7023ce231f XDOCKER-427 Open

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

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-957fddd0-5dd8-4237-8068-7c0b1a95f561 Vincent Massol created this issue on 04/Aug/26 20:13
 
Summary: XWiki is deployed twice when CONTEXT_PATH is set to something other than ROOT
Issue Type: cid:jira-generated-image-avatar-3f874493-3d3f-4d2c-8aee-9d7023ce231f Bug
Assignee: Unassigned
Created: 04/Aug/26 20:13
Priority: cid:jira-generated-image-static-major-cd6f2b0f-6d85-419d-996b-920eabd92483 Major
Reporter: Vincent Massol
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 browsing the root URL returns a 404 while only http://localhost:8080/<CONTEXT_PATH> works. The log fills up with hundreds of those errors.

Steps to reproduce

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

Cause

configure() in xwiki/docker-entrypoint.sh deploys the 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, 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, which Docker creates before the entrypoint runs when such a mount is declared.

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

Affected versions

Every image 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.

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.

 
 

2 updates

 
cid:jira-generated-image-avatar-957fddd0-5dd8-4237-8068-7c0b1a95f561 Changes by Vincent Massol on 04/Aug/26 20:14
 
Description: Reported on the forum: [ https://forum.xwiki.org/t/xwiki \ -deploying \ -twice \ -when \ -context \ -path \ -variable \ -is \ -set \ -up/18732 |https://forum.xwiki.org/t/xwiki-deploying-twice-when-context-path-variable-is-set-up/18732]

h2. Problem

When the {{ CONTEXT\_PATH 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 :

{ code}
{ The 'org.xwiki.infinispan' JMX domain is already in use
{code
}

} and browsing the log then fills up with hundreds of those errors. Browsing the root URL returns a 404 while and only {{http://localhost:8080/< CONTEXT\_PATH CONTEXT_PATH >}} works. The log fills up with hundreds of those errors.

h2. Steps to reproduce

# Go to {{18.4/postgres \ -tomcat}}.
# Add {{
CONTEXT\_PATH CONTEXT_PATH : wiki}} to the environment of the {{web}} service environment in {{docker \ -compose.yml}}.
#
Run {{docker compose up}}.

h2. Cause

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

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

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, which and Docker creates that directory before the entrypoint runs when such a mount is declared.

The copy
itself is correct fine , but nothing removes {{/usr/local/tomcat/webapps/ROOT}} afterwards , and Tomcat auto \ -deploys *every* directory under {{webapps/}}. So both {{ROOT}} and {{$CONTEXT\_PATH}} are 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.

h2. Affected versions
Every image
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.

h2. Verification

Reproduced on the published {{xwiki:18.4.0 \ -postgres \ -tomcat}} image with {{ CONTEXT\_PATH 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.

h2. 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.
Assignee: Vincent Massol
 
 

1 comment

 
cid:jira-generated-image-avatar-957fddd0-5dd8-4237-8068-7c0b1a95f561 Vincent Massol on 04/Aug/26 20:21
 

Fix in https://github.com/xwiki/xwiki-docker/pull/101