Wiki source code of Configure Derby

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

Show last authors
1 {{warning}}
2 Derby is not one of the [[databases XWiki supports>>dev:Community.SupportStrategy.DatabaseSupportStrategy]] and gets no regular testing. Check the [[supported databases>>dev:Community.SupportStrategy.DatabaseSupportStrategy]].
3 {{/warning}}
4
5 To configure XWiki to use [[Apache Derby>>https://db.apache.org/derby/]] in embedded mode, which runs inside the same JVM as XWiki and needs no database server to install or start:
6
7 1. Make sure you have already installed and [[configured a servlet container>>doc:documentation.xs.admin.installation.servlet-container.WebHome]] for XWiki (e.g. [[Tomcat>>doc:documentation.xs.admin.installation.servlet-container.configure-tomcat.WebHome]] or [[Jetty>>doc:documentation.xs.admin.installation.servlet-container.configure-jetty.WebHome]]), with the [[XWiki WAR>>doc:documentation.xs.admin.installation.methods.install-xwiki-war.WebHome]] file extracted/deployed.
8 1. Download the Derby release built for the Java version your servlet container runs, from the [[Apache Derby website>>https://db.apache.org/derby/derby_downloads.html]] or from the [[Maven Central repository>>https://central.sonatype.com/artifact/org.apache.derby/derby]]. Derby 10.17 needs Java 21 or later and Derby 10.16 needs Java 17 or later.
9 1. Copy ##derby.jar##, ##derbyshared.jar## and ##derbytools.jar## into the ##WEB-INF/lib## directory of the expanded XWiki WAR. XWiki ships none of them.(((
10 {{code language="none"}}
11 $ cp derby.jar derbyshared.jar derbytools.jar /path/to/webapps/xwiki/WEB-INF/lib/
12 {{/code}}
13 )))
14 1. Edit the ##WEB-INF/hibernate.cfg.xml## file, comment out the database block that is currently active and uncomment the Derby one, replacing ##/some/path/xwikidb## with the directory where you want the database files.(((
15 {{code language="xml"}}
16 <property name="hibernate.connection.url">jdbc:derby:/some/path/xwikidb;create=true</property>
17 <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
18 <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
19 <property name="hibernate.dbcp.poolPreparedStatements">true</property>
20 <property name="hibernate.dbcp.maxOpenPreparedStatements">20</property>
21
22 <property name="hibernate.connection.charSet">UTF-8</property>
23 <property name="hibernate.connection.useUnicode">true</property>
24 <property name="hibernate.connection.characterEncoding">utf8</property>
25
26 <mapping resource="xwiki.derby.hbm.xml"/>
27 <mapping resource="feeds.hbm.xml"/>
28 <mapping resource="instance.hbm.xml"/>
29 <mapping resource="notification-filter-preferences.hbm.xml"/>
30 {{/code}}
31 )))
32 1. Add the mail sender mapping to that list, which the shipped Derby block is missing.(((
33 {{code language="xml"}}
34 <mapping resource="mailsender.hbm.xml"/>
35 {{/code}}
36 )))
37 1. Start or restart the application server. XWiki creates the database directory and its tables on the first run.
38 1. Verify that the directory you configured now exists and holds Derby's ##service.properties## file and ##seg0## directory.(((
39 {{code language="none"}}
40 $ ls /some/path/xwikidb
41 README_DO_NOT_TOUCH_FILES.txt db.lck dbex.lck log seg0 service.properties tmp
42 {{/code}}
43 )))

Get Connected