Unable to use XWiki as Docker container / Migration fails

Hello together,

i wanted to give XWiki another try as an alternative to Confluence. Unfortunately i am not able to use XWiki as a Docker container. I used the official documentation to do this.

I had already a MariaDB so i used the following SQL:

create database xwiki;
create user 'xwiki' identified by 'xwiki';
grant all privileges on xwiki.* to 'xwiki';

I logged in as xwiki-user to the database and everything worked without any issues. So the database/credentials are correct.

As the next step i started my container as written in the docs:

docker run --name xwiki \
  -p 5000:8080 -d \
  -e DB_USER=xwiki \
  -e DB_PASSWORD=xwiki \
  -e DB_DATABASE=xwiki \
  -e DB_HOST= \

When i open the url (localhost:5000) i see “XWiki is initializing (12%)…” and then an error message (HTTP 500) appears (see following screenshot):
Bildschirmfoto 2020-12-30 um 17.33.51

The command docker logs xwiki displays some kind of “Database Migration issues”:

Configuring XWiki...
Setting environment variables
  Deploying XWiki in the 'ROOT' context
Replacing environment variables in files
  Generating authentication validation and encryption keys...
  Setting permanent directory...
  Configure libreoffice...
  Saving config file hibernate.cfg.xml...
  Saving config file xwiki.cfg...
  Saving config file xwiki.properties...
2020-12-30 16:26:19,324 [localhost-startStop-1] INFO  iPropertiesConfigurationSource - Loading [xwiki.properties] from [file:/usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.properties] 
2020-12-30 16:26:19,820 [localhost-startStop-1] INFO  o.x.e.i.ServletEnvironment     - Using permanent directory [/usr/local/xwiki/data] 
2020-12-30 16:26:33,705 [localhost-startStop-1] INFO  o.x.s.s.i.EmbeddedSolr         - Generating a new Solr home directory at [/usr/local/xwiki/data/store/solr] 
2020-12-30 16:26:33,750 [localhost-startStop-1] INFO  o.x.s.s.i.EmbeddedSolr         - Starting embedded Solr server... 
2020-12-30 16:26:33,750 [localhost-startStop-1] INFO  o.x.s.s.i.EmbeddedSolr         - Using Solr home directory: [/usr/local/xwiki/data/store/solr] 
2020-12-30 16:26:36,051 [localhost-startStop-1] WARN  o.e.j.u.s.S.config             - Trusting all certificates configured for Client@31859374[provider=null,keyStore=null,trustStore=null] 
2020-12-30 16:26:36,052 [localhost-startStop-1] WARN  o.e.j.u.s.S.config             - No Client EndPointIdentificationAlgorithm configured for Client@31859374[provider=null,keyStore=null,trustStore=null] 
2020-12-30 16:26:36,614 [localhost-startStop-1] WARN  o.e.j.u.s.S.config             - Trusting all certificates configured for Client@49877120[provider=null,keyStore=null,trustStore=null] 
2020-12-30 16:26:36,615 [localhost-startStop-1] WARN  o.e.j.u.s.S.config             - No Client EndPointIdentificationAlgorithm configured for Client@49877120[provider=null,keyStore=null,trustStore=null] 
2020-12-30 16:26:36,678 [localhost-startStop-1] WARN  o.a.s.c.CoreContainer          - Not all security plugins configured!  authentication=disabled authorization=disabled.  Solr is only as secure as you make it. Consider configuring authentication/authorization before exposing Solr to users internal or external.  See https://s.apache.org/solrsecurity for more info 
2020-12-30 16:26:44,031 [localhost-startStop-1] INFO  o.x.s.s.i.EmbeddedSolr         - Started embedded Solr server. 
2020-12-30 16:27:03,160 [localhost-startStop-1] INFO  o.x.s.f.i.FilesystemStoreTools - Using filesystem store directory [/usr/local/xwiki/data/store/file] 
2020-12-30 16:27:04,610 [OfficeProcessThread-0] WARN  o.j.o.ConnectRetryable         - Office process died with exit code 81; restarting it 
2020-12-30 16:27:05,279 [localhost-startStop-1] INFO  o.x.o.i.s.DefaultOfficeServer  - Open Office instance started. 
2020-12-30 16:29:30,461 [XWiki initialization] INFO  .HibernateDataMigrationManager - Storage schema updates and data migrations are enabled 
2020-12-30 16:29:30,844 [XWiki initialization] INFO  .HibernateDataMigrationManager - The following data migration(s) will be applied for wiki [xwiki] currently in version [4340]: 
2020-12-30 16:29:30,845 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R4359XWIKI1459 - See https://jira.xwiki.org/browse/XWIKI-1459 
2020-12-30 16:29:30,845 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R6405XWIKI1933 - See https://jira.xwiki.org/browse/XWIKI-1933 
2020-12-30 16:29:30,845 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R7345XWIKI2079 - See https://jira.xwiki.org/browse/XWIKI-2079 
2020-12-30 16:29:30,846 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R15428XWIKI2977 - Add a GUID to existing objects when upgrading from pre-1.8M1. 
2020-12-30 16:29:30,846 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R40000XWIKI6990 - Convert document IDs to use the new improved hash algorithm. 
2020-12-30 16:29:30,846 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R40001XWIKI7540 - See https://jira.xwiki.org/browse/XWIKI-7540 
2020-12-30 16:29:30,846 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R43000XWIKI6691 - Reduce the size of the ASE_REQUESTID column to 48-chars 
2020-12-30 16:29:30,846 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R530000WorkspacesMigration - https://jira.xwiki.org/browse/XWIKI-9738 
2020-12-30 16:29:30,847 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R54000WikiTemplateMigration - https://jira.xwiki.org/browse/XWIKI-9934 
2020-12-30 16:29:30,847 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R54300WikiDescriptorMigration - https://jira.xwiki.org/browse/XWIKI-10091 
2020-12-30 16:29:30,847 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R54600Translation - Fix any existing mistake with document translation field 
2020-12-30 16:29:30,847 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R72000XWIKI12153 - Convert document space name into space reference 
2020-12-30 16:29:30,847 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R72001XWIKI12228 - Make sure xwikidocument and xwikispace tables are in sync 
2020-12-30 16:29:30,848 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R73000XWIKI12277 - Migrate TemplateProviderClass' removed 'type' property values to the new 'terminal' property. 
2020-12-30 16:29:30,848 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R90000XWIKI13474 - Convert attachment size type to BIGINT to allow attachments bigger than 2GB. 
2020-12-30 16:29:30,848 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R93000RecordableEventMigrator - https://jira.xwiki.org/browse/XWIKI-14172 
2020-12-30 16:29:30,848 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R910000XWIKI14697 - Make sure all attachments have the right content store id. 
2020-12-30 16:29:30,848 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R910001XWIKI14697 - Make sure all attachments have the right archive store id. 
2020-12-30 16:29:30,848 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R910100XWIKI14871 - Make sure all existing deleted attachments have a store id and move back metadata to the database. 
2020-12-30 16:29:30,849 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R911000XWIKI14889 - Remove the non-null=true from deleted attachments table. 
2020-12-30 16:29:30,849 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R911001XWIKI14895 - Remove the non-null=true from deleted documents table. 
2020-12-30 16:29:30,849 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R1004000XWIKI15249 - Make sure all attachments have the right content store id. 
2020-12-30 16:29:30,849 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R1004001XWIKI15249 - Make sure all attachments have the right archive store id. 
2020-12-30 16:29:30,849 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R1008010XWIKI10092 - Add missing properties to existing objects. 
2020-12-30 16:29:30,849 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R1100000XWIKI15620 - Move the store to a new location. Change the path from URL encoding to hash based to support long references. 
2020-12-30 16:29:30,850 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R1130000WatchlistLeftoversCleaner - Remove some mandatory documents created by the Watchlist Application that the notification email notifier replaces. 
2020-12-30 16:29:30,850 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R1130040XWIKI16682 - Fix attachments content store id missed because of a bug in migration R1100000XWIKI15620 
2020-12-30 16:29:30,850 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R1138000XWIKI16709 - Remove disable property and add checked_email property in XWikiUser documents. 
2020-12-30 16:29:30,850 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R120901000XWIKI17761 - Move old Ratings XObject to the default Solr rating store. 
2020-12-30 16:29:30,850 [XWiki initialization] INFO  .HibernateDataMigrationManager -   R121001000XWIKI18145 - Ensure that foreign keys have the proper name. 
2020-12-30 16:29:31,409 [XWiki initialization] INFO  .HibernateDataMigrationManager - Running early schema updates (using liquibase) for database [xwiki] 
2020-12-30 16:29:36,826 [XWiki initialization] INFO  .HibernateDataMigrationManager - Checking Hibernate mapping and updating schema if needed for wiki [xwiki] 
2020-12-30 16:29:37,596 [XWiki initialization] INFO  h.R40000XWIKI6990DataMigration - [R40000XWIKI6990] - 32 schema updates required. 
2020-12-30 16:29:37,599 [XWiki initialization] INFO  .HibernateDataMigrationManager - Running additional schema updates (using liquibase) for database [xwiki] 
2020-12-30 16:29:38,458 [XWiki initialization] INFO  .HibernateDataMigrationManager - Starting data migration [R4359XWIKI1459] with version [4359] on database [xwiki] 
2020-12-30 16:29:38,515 [XWiki initialization] WARN  o.h.e.j.s.SqlExceptionHelper   - SQL Error: 1054, SQLState: 42S22 
2020-12-30 16:29:38,516 [XWiki initialization] ERROR o.h.e.j.s.SqlExceptionHelper   - Unknown column 'XWD_ARCHIVE' in 'field list' 
2020-12-30 16:29:38,551 [XWiki initialization] ERROR .HibernateDataMigrationManager - Failed to migrate database [xwiki]... 
com.xpn.xwiki.store.migration.DataMigrationException: Data migration R4359XWIKI1459 failed
	at com.xpn.xwiki.store.migration.hibernate.AbstractHibernateDataMigration.migrate(AbstractHibernateDataMigration.java:120)
	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.startMigrations(AbstractDataMigrationManager.java:837)
	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.migrateDatabase(AbstractDataMigrationManager.java:736)
	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.startMigrations(AbstractDataMigrationManager.java:657)
	at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.startMigrations(HibernateDataMigrationManager.java:361)
	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.startMigrationsOnlyOnce(AbstractDataMigrationManager.java:637)
	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.tryToProcceedToMigration(AbstractDataMigrationManager.java:614)
	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:539)
	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.setWiki(HibernateStore.java:672)
	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.setWiki(HibernateStore.java:633)
	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.beginTransaction(HibernateStore.java:811)
	at com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:577)
	at com.xpn.xwiki.store.XWikiHibernateStore.loadXWikiDoc(XWikiHibernateStore.java:976)
	at com.xpn.xwiki.store.XWikiCacheStore.loadXWikiDoc(XWikiCacheStore.java:394)
	at com.xpn.xwiki.XWiki.getDocument(XWiki.java:2144)
	at com.xpn.xwiki.XWiki.getDocument(XWiki.java:2206)
	at com.xpn.xwiki.XWiki.initializeMandatoryDocument(XWiki.java:1418)
	at com.xpn.xwiki.XWiki.initializeMandatoryDocuments(XWiki.java:1385)
	at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:1290)
	at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:1227)
	at com.xpn.xwiki.XWiki.<init>(XWiki.java:1200)
	at com.xpn.xwiki.internal.XWikiInitializerJob.runInternal(XWikiInitializerJob.java:117)
	at org.xwiki.job.AbstractJob.runInContext(AbstractJob.java:243)
	at org.xwiki.job.AbstractJob.run(AbstractJob.java:220)
	at java.base/java.lang.Thread.run(Thread.java:834)

This issue occurs when i use “volume mounting (-v)” in docker or not.

During writing this post (and installing xwiki via docker) i might have find something:

  • I started the container once with a missing -d parameter. So i pressed CTRL + C to exit the docker run command. docker start xwiki didn’t worked and i re-created the container with all parameters. My current container is the one listed above.
    The initialization failed continuously. Maybe there was no “clean” shutdown as i pressed CTRL + C.

  • I deleted the database multiple times and used the identical container by using docker stop xwiki and docker start xwiki. I wanted to force the migration.

drop database xwiki;
create database xwiki;
grant all privileges on xwiki.* to 'xwiki';

I had to re-create the database 2-3 times (see SQL above) until the Distribution Wizard/Start
page could be displayed. I ensured there is only one single xwiki container running.
I stopped and deleted (rm) every container before i ran a new one.

I am unsure if this is a time-to-time issue or if it can be forced somehow so startups in the future are smoother.

Best regards

I guess you mean an old XWiki database (seems to be something like XWiki 4.x), which means you’re not installing XWiki but upgrading it.

In any case your DB schema seems incorrect, for example:

2020-12-30 16:29:38,515 [XWiki initialization] WARN  o.h.e.j.s.SqlExceptionHelper   - SQL Error: 1054, SQLState: 42S22 
2020-12-30 16:29:38,516 [XWiki initialization] ERROR o.h.e.j.s.SqlExceptionHelper   - Unknown column 'XWD_ARCHIVE' in 'field list'

I’d highly recommend that you start with a clean database container. And if you wish to import some past xwiki content that you export it using the XAR format (but only your content and not the default xwiki pages) and reimport in the new instance.

Sorry for my late response. No: I mean i have a MariaDB (just to clarify that i didn’t run MariaDB in Docker). I tried to simulate how this exception ocurrs.

I created a new/empty database (by drop and create commands).
When you stop xwiki (e.g. docker stop) during the “website initialization” (Website shows “initialize 20%…” message) the database is in a “broken state”.

If your server is not stopped during initialization, the databse seems to be healthy so it can be used without any issues.

Maybe this was my issue before that the startup failed somehow (or i accidentaly stopped it) and i assumed it’s transaction-safe so there is no “broken state” in the database. So i ran into the issue because a stop caused the database to be broken and the following xwiki-restarts failed because the database was invalid.

I had no prior xwiki-data which i wanted to import.
Thank you again for your support (here and via Twitter). I am playing around with xwiki and its plugins.

Best regards