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

Show last authors
1 {{warning}}
2 GlassFish is not an [[officially supported servlet container>>dev:Community.SupportStrategy.ServletContainerSupportStrategy.WebHome]]: these instructions are contributed by the community and receive no testing from the XWiki project.
3 {{/warning}}
4
5 Create the ##jdbc/xwiki## data source that [[Use a Container-Managed Data Source>>doc:documentation.xs.admin.installation.database.use-container-managed-data-source.WebHome]] asks for, so that [[GlassFish>>doc:documentation.xs.admin.installation.servlet-container.configure-glassfish.WebHome]] opens XWiki's database connections instead of XWiki opening them itself. The commands below use MySQL.
6
7 1. Copy the [[MySQL JDBC driver>>doc:documentation.xs.admin.installation.database.configure-mysql.WebHome]] into ##GLASSFISH_HOME/glassfish/domains/domain1/lib##, and not into the web application's ##WEB-INF/lib##, so that GlassFish itself can load it. GlassFish picks it up without a restart since version 7.0.18; on an earlier release, restart the domain with ##asadmin restart-domain##.
8 1. Create the connection pool. Quote the property list and escape every colon inside it with a backslash, since ##asadmin## reads the colon as its property separator:(((
9 {{code language="bash"}}
10 GLASSFISH_HOME/bin/asadmin create-jdbc-connection-pool \
11 --datasourceclassname com.mysql.cj.jdbc.MysqlConnectionPoolDataSource \
12 --restype javax.sql.ConnectionPoolDataSource \
13 --property 'User=xwiki:Password=xwiki:URL=jdbc\:mysql\://localhost\:3306/xwiki' \
14 --isolationlevel read-committed \
15 --maxpoolsize 50 \
16 --statementcachesize 20 \
17 jdbc/xwikipool
18 {{/code}}
19
20 The last three options 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. Left out, the isolation level is whatever the JDBC driver defaults to, and the statement cache size is ##0##, meaning no caching at all.
21 )))
22 1. Check that the pool reaches the database:(((
23 {{code language="none"}}
24 GLASSFISH_HOME/bin/asadmin ping-connection-pool jdbc/xwikipool
25 {{/code}}
26
27 It answers ##Command ping-connection-pool executed successfully.## If it fails instead, delete the pool with ##asadmin delete-jdbc-connection-pool jdbc/xwikipool## and create it again with corrected values.
28 )))
29 1. Create the JDBC resource, naming it ##jdbc/xwiki##:(((
30 {{code language="bash"}}
31 GLASSFISH_HOME/bin/asadmin create-jdbc-resource --connectionpoolid jdbc/xwikipool jdbc/xwiki
32 {{/code}}
33 )))
34 1. List the resources:(((
35 {{code language="none"}}
36 GLASSFISH_HOME/bin/asadmin list-jdbc-resources
37 {{/code}}
38
39 ##jdbc/xwiki## appears beside GlassFish's own ##jdbc/~_~_TimerPool## and ##jdbc/~_~_default##. Point XWiki at it by following [[Use a Container-Managed Data Source>>doc:documentation.xs.admin.installation.database.use-container-managed-data-source.WebHome]].
40 )))

Get Connected