Last modified by Eleni Cojocariu on 2026/11/25 14:50

Show last authors
1 Have [[WildFly>>doc:documentation.xs.admin.installation.servlet-container.configure-wildfly.WebHome]] open XWiki's database connections instead of XWiki opening them itself, which is the WildFly half of [[Use a Container-Managed Data Source>>doc:documentation.xs.admin.installation.database.use-container-managed-data-source.WebHome]]. The commands below use MySQL.
2
3 1. Register the JDBC driver of your database as a JBoss Module, so that WildFly loads it rather than the XWiki web application. For [[MySQL>>doc:documentation.xs.admin.installation.database.configure-mysql.WebHome]]:(((
4 {{code language="bash"}}
5 WILDFLY_HOME/bin/jboss-cli.sh "embed-server, module add --name=com.mysql \
6 --resources=/path/to/mysql-connector-j-x.y.z.jar \
7 --dependencies=java.se,jakarta.transaction.api"
8 {{/code}}
9
10 The command writes the module descriptor itself. Take the driver JAR, at its latest version, from the page of your [[database>>doc:documentation.xs.admin.installation.database.WebHome]].
11 )))
12 1. Declare the data source:(((
13 {{code language="bash"}}
14 WILDFLY_HOME/bin/jboss-cli.sh "embed-server --server-config=standalone.xml, \
15 data-source add --name=XWikiDS --jndi-name=java:jboss/datasources/XWikiDS \
16 --driver-name=com.mysql --connection-url=jdbc:mysql://localhost:3306/xwiki \
17 --user-name=xwiki --password=xwiki \
18 --transaction-isolation=TRANSACTION_READ_COMMITTED \
19 --max-pool-size=50 --prepared-statements-cache-size=20 --share-prepared-statements=true"
20 {{/code}}
21
22 This writes the matching data source and driver elements into ##WILDFLY_HOME/standalone/configuration/standalone.xml##. Should you need XA transactions, the MySQL driver class to declare is ##com.mysql.cj.jdbc.MysqlXADataSource##.
23
24 The last four settings are not tuning: they replace what XWiki's own pool was providing, which [[Use a Container-Managed Data Source>>doc:documentation.xs.admin.installation.database.use-container-managed-data-source.WebHome]] explains. WildFly would otherwise apply its own defaults of 20 connections, no statement cache and whatever isolation level the driver chooses.
25 )))
26 1. Point Hibernate at it in ##WEB-INF/hibernate.cfg.xml##, as [[Use a Container-Managed Data Source>>doc:documentation.xs.admin.installation.database.use-container-managed-data-source.WebHome]] describes, with two differences that are WildFly's:(((
27 {{code language="xml"}}
28 <property name="hibernate.connection.datasource">java:jboss/datasources/XWikiDS</property>
29 {{/code}}
30
31 The name is absolute, since WildFly binds data sources under ##java:jboss/datasources## and not under the ##java:comp/env## that page uses for Tomcat. And ##hibernate.connection.provider_class## goes as well, since the connection pool it names would otherwise keep opening the connections itself.
32 )))
33 1. Restart WildFly, then check that the connections now come from its pool:(((
34 {{code language="none"}}
35 WILDFLY_HOME/bin/jboss-cli.sh --connect "/subsystem=datasources/data-source=XWikiDS:test-connection-in-pool"
36 {{/code}}
37
38 It answers with an outcome of ##success##, and XWiki serves its pages as before.
39 )))

Get Connected