"Error executing DDL" SQL Server Error

Last modified by superadmin on 2026/11/25 21:31

SQL Server has no schema named after the wiki's database, so Hibernate cannot create XWiki's tables until the schema is created.

Explanation

XWiki fails to start against a SQL Server database, and the logs show a CommandAcceptanceException on the first table Hibernate tries to create:

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL
  "create table xwiki.xwikidoc (...)" via JDBC Statement

Running the same statement by hand against the database reports what the stack trace does not:

The specified schema name "xwiki" either does not exist or you do not have permission to use it.

Cause

XWiki qualifies every table it maps with the name of the wiki's database, which is the xwiki.db property of the WEB-INF/xwiki.cfg file for the main wiki and the subwiki's identifier for a subwiki, and which defaults to xwiki. SQL Server reads that qualifier as a schema name, so Hibernate emits create table xwiki.xwikidoc. Hibernate generates create table statements and never a create schema, so unless a schema of that name already exists the very first statement fails and no table is created at all.

The name does not come from the default schema of the user the login maps to, so neither making the login the owner of the database nor pointing that user at dbo avoids the failure: both leave the statement qualified with xwiki. Creating the tables under dbo by hand does not help either, since XWiki still looks for them under xwiki.

The same mismatch shows the other way round after a server migration that moves the tables under a schema whose name is not the one XWiki asks for: XWiki then finds nothing and reports that the object does not exist.

Information

Do not fix this by editing the table attributes in xwiki.mssql.hbm.xml. That file ships inside XWiki and is replaced on every upgrade, so the edit is lost the next time you upgrade, and until then it hides the mismatch rather than resolving it.

XWIKI-18318 records this. It is closed as invalid, the schema being a database-side prerequisite rather than an XWiki defect.

Solution

  1. Stop XWiki, so that nothing retries the schema update while you work.
  2. Read the schema name XWiki asks for: it is the xwiki.db property of the WEB-INF/xwiki.cfg file, and xwiki when that property is left commented out.
  3. Connect to the XWiki database as an administrator and list the schemas it already holds.
    USE xwiki;
    GO
    SELECT name FROM sys.schemas ORDER BY name;
    GO
  4. Create the missing schema, owned by dbo, which is what a login owning the database maps to.
    CREATE SCHEMA xwiki AUTHORIZATION dbo;
    GO
  5. Start XWiki again.
  6. The start-up completes, and XWiki creates its tables under that schema.

Related

Get Connected