Use a Container-Managed Data Source
Last modified by Eleni Cojocariu on 2026/08/13 16:22
Steps
By default XWiki opens its own connections to the database, from the settings in its WEB-INF/hibernate.cfg.xml file. To let the servlet container manage the connection pool instead, and have XWiki take its connections from a JNDI data source:
- Copy the JDBC driver of your database into the library directory of the servlet container rather than into the WEB-INF/lib directory of the XWiki web application, for example $CATALINA_HOME/lib on Tomcat.
- Declare a data source named jdbc/xwiki in the servlet container. On Tomcat, declare it as a resource, either from the Manager web application or in the conf/Catalina/<host>/<webapp-name>.xml file.
- Replace the connection settings in your database's block of WEB-INF/hibernate.cfg.xml with the name of that data source, removing the hibernate.connection.url, hibernate.connection.username, hibernate.connection.password and hibernate.connection.driver_class properties:
<property name="hibernate.connection.datasource">java:comp/env/jdbc/xwiki</property> <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property> - Restart the servlet container.
- Verify that XWiki starts and serves its pages, and that the servlet container reports connections being taken from the jdbc/xwiki data source.
FAQ
Do I still need a connection provider class?
No. Leave hibernate.connection.provider_class unset, so that Hibernate uses its own data source provider. XWiki's DBCPConnectionProvider builds its own pool from the connection URL and does not handle container-managed data sources.
Do I have to set the dialect?
No. Hibernate detects it from the database it connects to, so set hibernate.dialect explicitly only if you want to pin a specific dialect.