This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 8f6d59865e JAMES-4155 Drop now retired Derby in favor of H2 (#2875)
8f6d59865e is described below
commit 8f6d59865e1263cbd51bd0719c4d821fea8b3bf2
Author: Benoit TELLIER <[email protected]>
AuthorDate: Fri Dec 19 08:54:01 2025 +0100
JAMES-4155 Drop now retired Derby in favor of H2 (#2875)
---
backends-common/jpa/pom.xml | 15 +++------
.../james/backends/jpa/JPAConfiguration.java | 8 +----
.../apache/james/backends/jpa/JpaTestCluster.java | 5 +--
event-sourcing/event-store-jpa/pom.xml | 17 ++++------
.../src/test/resources/persistence.xml | 1 +
mailbox/jpa/pom.xml | 9 ++----
.../src/main/resources/james-database.properties | 6 ++--
mailbox/jpa/src/test/resources/persistence.xml | 1 +
mailbox/spring/pom.xml | 12 +++-----
.../META-INF/org/apache/james/database.properties | 4 +--
.../src/test/resources/META-INF/persistence.xml | 1 +
.../testdata/VirtualRepositoryMix.xml | 6 ++--
mpt/impl/imap-mailbox/jpa/pom.xml | 9 ++----
pom.xml | 18 +++++------
server/apps/jpa-app/README.adoc | 2 +-
server/apps/jpa-app/pom.xml | 16 ++++------
.../sample-configuration/james-database.properties | 6 ++--
.../src/main/resources/META-INF/persistence.xml | 1 +
server/apps/jpa-smtp-app/README.adoc | 2 +-
server/apps/jpa-smtp-app/pom.xml | 16 ++++------
.../sample-configuration/james-database.properties | 6 ++--
.../src/main/resources/META-INF/persistence.xml | 1 +
.../mariadb/TestJPAMariaDBConfigurationModule.java | 1 +
.../sample-configuration/james-database.properties | 6 ++--
.../src/main/resources/META-INF/persistence.xml | 1 +
server/apps/spring-app/pom.xml | 13 +++-----
.../resources/META-INF/persistence-template.xml | 2 ++
.../src/main/resources/META-INF/persistence.xml | 1 +
.../src/main/resources/james-database.properties | 6 ++--
.../spring-app/src/main/resources/sqlResources.xml | 14 ++++-----
server/container/guice/jpa-common/pom.xml | 9 ++----
.../james/modules/data/JPAEntityManagerModule.java | 12 ++++++++
.../apache/james/TestJPAConfigurationModule.java | 4 +--
...estJPAConfigurationModuleWithSqlValidation.java | 36 +++++-----------------
server/data/data-jpa/pom.xml | 15 +++------
.../james/sieve/jpa/model/JPASieveScript.java | 14 +++++----
.../data-jpa/src/test/resources/persistence.xml | 1 +
...e-of-conditional-statements-in-guice-modules.md | 4 +--
src/site/xdoc/download.xml | 4 +--
.../xdoc/server/config-spring-jpa-postgres.xml | 2 +-
src/site/xdoc/server/dev.xml | 2 +-
src/site/xdoc/server/install.xml | 2 +-
src/site/xdoc/server/monitor-folders.xml | 6 ++--
src/site/xdoc/server/packaging.xml | 6 ++--
src/site/xdoc/server/quick-start.xml | 2 +-
45 files changed, 137 insertions(+), 188 deletions(-)
diff --git a/backends-common/jpa/pom.xml b/backends-common/jpa/pom.xml
index dc1ab1a4ac..723a4936dd 100644
--- a/backends-common/jpa/pom.xml
+++ b/backends-common/jpa/pom.xml
@@ -38,6 +38,11 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
@@ -47,16 +52,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
diff --git
a/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConfiguration.java
b/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConfiguration.java
index 27a2d4970e..876de48ffd 100644
---
a/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConfiguration.java
+++
b/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConfiguration.java
@@ -28,8 +28,6 @@ import static
org.apache.james.backends.jpa.JPAConfiguration.ReadyToBuild.NO_TES
import static
org.apache.james.backends.jpa.JPAConfiguration.ReadyToBuild.NO_VALIDATION_QUERY;
import static
org.apache.james.backends.jpa.JPAConfiguration.ReadyToBuild.NO_VALIDATION_QUERY_TIMEOUT_SEC;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -47,13 +45,11 @@ public class JPAConfiguration {
public static final String JPA_CONNECTION_PROPERTIES =
"openjpa.ConnectionProperties";
public static final String JPA_CONNECTION_URL = "openjpa.ConnectionURL";
public static final String JPA_MULTITHREADED = "openjpa.Multithreaded";
- public static final List<String> DEFAULT_JPA_PROPERTIES =
List.of(JPA_CONNECTION_DRIVER_NAME, JPA_CONNECTION_URL, JPA_MULTITHREADED,
JPA_CONNECTION_USERNAME, JPA_CONNECTION_PASSWORD);
public static final String DATASOURCE_TEST_ON_BORROW =
"datasource.testOnBorrow";
public static final String DATASOURCE_VALIDATION_QUERY_TIMEOUT_SEC =
"datasource.validationQueryTimeoutSec";
public static final String DATASOURCE_VALIDATION_QUERY =
"datasource.validationQuery";
public static final String DATASOURCE_MAX_TOTAL = "datasource.maxTotal";
- public static final List<String> DEFAULT_DATASOURCE_PROPERTIES =
List.of(DATASOURCE_TEST_ON_BORROW, DATASOURCE_VALIDATION_QUERY_TIMEOUT_SEC,
DATASOURCE_VALIDATION_QUERY, DATASOURCE_MAX_TOTAL);
public static final String ATTACHMENT_STORAGE =
"attachmentStorage.enabled";
@@ -199,14 +195,12 @@ public class JPAConfiguration {
}
public ReadyToBuild setCustomDatasourceProperties(Map<String, String>
customDatasourceProperties) {
- this.customDatasourceProperties = new
HashMap<>(customDatasourceProperties);
-
DEFAULT_DATASOURCE_PROPERTIES.forEach(this.customDatasourceProperties::remove);
+ this.customDatasourceProperties = customDatasourceProperties;
return this;
}
public ReadyToBuild setCustomOpenjpaProperties(Map<String, String>
customOpenjpaProperties) {
this.customOpenjpaProperties = customOpenjpaProperties;
-
DEFAULT_JPA_PROPERTIES.forEach(this.customOpenjpaProperties::remove);
return this;
}
diff --git
a/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java
b/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java
index f4496bdb9e..f8ba96aafd 100644
---
a/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java
+++
b/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java
@@ -38,8 +38,9 @@ public class JpaTestCluster {
public static JpaTestCluster create(List<Class<?>> clazz) {
HashMap<String, String> properties = new HashMap<>();
- properties.put("openjpa.ConnectionDriverName",
org.apache.derby.jdbc.EmbeddedDriver.class.getName());
- properties.put("openjpa.ConnectionURL",
"jdbc:derby:memory:mailboxintegrationtesting;create=true"); // Memory Derby
database
+ properties.put("openjpa.ConnectionDriverName",
org.h2.Driver.class.getName());
+ properties.put("openjpa.ConnectionURL",
"jdbc:h2:mem:mailboxintegrationtesting;DB_CLOSE_DELAY=-1"); // Memory H2
database
+ properties.put("openjpa.jdbc.DBDictionary", "h2");
properties.put("openjpa.jdbc.SynchronizeMappings",
"buildSchema(ForeignKeys=true)"); // Create Foreign Keys
properties.put("openjpa.jdbc.SchemaFactory",
"native(ForeignKeys=true)");
properties.put("openjpa.jdbc.MappingDefaults",
"ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade");
diff --git a/event-sourcing/event-store-jpa/pom.xml
b/event-sourcing/event-store-jpa/pom.xml
index a586fc13e8..59e78dad09 100644
--- a/event-sourcing/event-store-jpa/pom.xml
+++ b/event-sourcing/event-store-jpa/pom.xml
@@ -74,6 +74,11 @@
<artifactId>testing-base</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
@@ -83,16 +88,6 @@
<artifactId>jakarta.transaction-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
@@ -135,4 +130,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/event-sourcing/event-store-jpa/src/test/resources/persistence.xml
b/event-sourcing/event-store-jpa/src/test/resources/persistence.xml
index fe4665d269..a40f34db51 100644
--- a/event-sourcing/event-store-jpa/src/test/resources/persistence.xml
+++ b/event-sourcing/event-store-jpa/src/test/resources/persistence.xml
@@ -29,6 +29,7 @@
<class>org.apache.james.eventsourcing.eventstore.jpa.model.JPAEvent</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git a/mailbox/jpa/pom.xml b/mailbox/jpa/pom.xml
index dd8c1f7329..e1225b0e53 100644
--- a/mailbox/jpa/pom.xml
+++ b/mailbox/jpa/pom.xml
@@ -119,13 +119,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/mailbox/jpa/src/main/resources/james-database.properties
b/mailbox/jpa/src/main/resources/james-database.properties
index 93ba6aa0f9..8e03f0303b 100644
--- a/mailbox/jpa/src/main/resources/james-database.properties
+++ b/mailbox/jpa/src/main/resources/james-database.properties
@@ -20,9 +20,9 @@
# See http://james.apache.org/server/3/config.html for usage
-# Use derby as default
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:../var/store/derby;create=true
+# Use H2 as default
+database.driverClassName=org.h2.Driver
+database.url=jdbc:h2:file:../var/store/h2db;DB_CLOSE_DELAY=-1
database.username=app
database.password=app
diff --git a/mailbox/jpa/src/test/resources/persistence.xml
b/mailbox/jpa/src/test/resources/persistence.xml
index ae8f4361d0..973d35ccae 100644
--- a/mailbox/jpa/src/test/resources/persistence.xml
+++ b/mailbox/jpa/src/test/resources/persistence.xml
@@ -42,6 +42,7 @@
<class>org.apache.james.mailbox.jpa.mail.model.JPAMailboxAnnotationId</class>
<class>org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMailboxMessage$MailboxIdUidKey</class>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git a/mailbox/spring/pom.xml b/mailbox/spring/pom.xml
index dd1ced4fcd..74c5fd7770 100644
--- a/mailbox/spring/pom.xml
+++ b/mailbox/spring/pom.xml
@@ -85,6 +85,10 @@
<artifactId>testing-base</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
@@ -95,14 +99,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
diff --git
a/mailbox/spring/src/test/resources/META-INF/org/apache/james/database.properties
b/mailbox/spring/src/test/resources/META-INF/org/apache/james/database.properties
index a852652c46..8d45e7e97e 100644
---
a/mailbox/spring/src/test/resources/META-INF/org/apache/james/database.properties
+++
b/mailbox/spring/src/test/resources/META-INF/org/apache/james/database.properties
@@ -18,7 +18,7 @@
# See http://james.apache.org/server/3/config.html for usage
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:target/var/store/derby;create=true
+database.driverClassName=org.h2.Driver
+database.url=jdbc:h2:file:target/var/store/h2db;DB_CLOSE_DELAY=-1
database.username=app
database.password=app
diff --git a/mailbox/spring/src/test/resources/META-INF/persistence.xml
b/mailbox/spring/src/test/resources/META-INF/persistence.xml
index bf27655a71..b612712423 100644
--- a/mailbox/spring/src/test/resources/META-INF/persistence.xml
+++ b/mailbox/spring/src/test/resources/META-INF/persistence.xml
@@ -41,6 +41,7 @@
<class>org.apache.james.mailbox.jpa.mail.model.JPAMailboxAnnotationId</class>
<class>org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMailboxMessage$MailboxIdUidKey</class>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
index 2b6b125225..1d1aa21597 100644
---
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
+++
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
@@ -59,16 +59,16 @@
value="mailboxmanager"/>
<property
name="torque.database.mailboxmanager.adapter"
- value="derby"/>
+ value="h2"/>
<property
name="torque.dsfactory.mailboxmanager.factory"
value="org.apache.torque.dsfactory.SharedPoolDataSourceFactory"/>
<property
name="torque.dsfactory.mailboxmanager.connection.driver"
- value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ value="org.h2.Driver"/>
<property
name="torque.dsfactory.mailboxmanager.connection.url"
-
value="jdbc:derby:tmp/mailboxmanager-derbydb;create=true"/>
+
value="jdbc:h2:file:tmp/mailboxmanager-h2db;DB_CLOSE_DELAY=-1"/>
<property
name="torque.dsfactory.mailboxmanager.connection.user"
value="app"/>
diff --git a/mpt/impl/imap-mailbox/jpa/pom.xml
b/mpt/impl/imap-mailbox/jpa/pom.xml
index 627bf5f911..400e88c47b 100644
--- a/mpt/impl/imap-mailbox/jpa/pom.xml
+++ b/mpt/impl/imap-mailbox/jpa/pom.xml
@@ -90,13 +90,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/pom.xml b/pom.xml
index 5e3c4ad094..4ec3b1367c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -624,7 +624,7 @@
<activemq.version>6.1.6</activemq.version>
<apache-mime4j.version>0.8.13</apache-mime4j.version>
<apache.openjpa.version>4.1.1</apache.openjpa.version>
- <derby.version>10.17.1.0</derby.version>
+ <h2.version>2.3.232</h2.version>
<log4j2.version>2.24.3</log4j2.version>
<jakarta.inject-api.version>2.0.1</jakarta.inject-api.version>
<jakarta.annotation-api.version>3.0.0</jakarta.annotation-api.version>
@@ -2283,6 +2283,11 @@
<artifactId>guice-assistedinject</artifactId>
<version>${guice.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ </dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
@@ -2699,16 +2704,6 @@
<artifactId>commons-text</artifactId>
<version>1.13.1</version>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${derby.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- <version>${derby.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
@@ -3840,6 +3835,7 @@
<exclude>release.properties</exclude>
<exclude>dist/**/*</exclude>
<exclude>**/derby.log</exclude>
+ <exclude>**/h2.log</exclude>
<!-- Eclipse -->
<exclude>**/.*</exclude>
<exclude>.*/**/*</exclude>
diff --git a/server/apps/jpa-app/README.adoc b/server/apps/jpa-app/README.adoc
index 746152709f..f8583f68de 100644
--- a/server/apps/jpa-app/README.adoc
+++ b/server/apps/jpa-app/README.adoc
@@ -1,6 +1,6 @@
= Guice-JPA Server How-to
-This server target single node James deployments. By default, the derby
database is used.
+This server target single node James deployments. By default, the H2 database
is used.
== Requirements
diff --git a/server/apps/jpa-app/pom.xml b/server/apps/jpa-app/pom.xml
index 3a71f96c62..5f068f1dc0 100644
--- a/server/apps/jpa-app/pom.xml
+++ b/server/apps/jpa-app/pom.xml
@@ -200,6 +200,10 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
<dependency>
<groupId>com.linagora</groupId>
<artifactId>logback-elasticsearch-appender</artifactId>
@@ -209,14 +213,6 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- </dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
@@ -321,7 +317,7 @@
<volume>/root/glowroot/data</volume>
<!-- Data for ActiveMQ mailQueue -->
<volume>/root/var</volume>
- <!-- Data for derby database -->
+ <!-- Data for H2 database -->
<volume>/var/store</volume>
</volumes>
<extraClasspath>/root/libs/james-jdbc-driver.jar</extraClasspath>
@@ -371,7 +367,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <!-- Isolation issues with Derby inMemory database -->
+ <!-- Isolation issues with H2 inMemory database -->
<reuseForks>false</reuseForks>
<!-- Speed up a bit things -->
<forkCount>1C</forkCount>
diff --git a/server/apps/jpa-app/sample-configuration/james-database.properties
b/server/apps/jpa-app/sample-configuration/james-database.properties
index 22f2871d1e..83ebfa8e5d 100644
--- a/server/apps/jpa-app/sample-configuration/james-database.properties
+++ b/server/apps/jpa-app/sample-configuration/james-database.properties
@@ -20,9 +20,9 @@
# Read
https://james.apache.org/server/config-system.html#james-database.properties
for further details
-# Use derby as default
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:../var/store/derby;create=true
+# Use H2 as default
+database.driverClassName=org.h2.Driver
+database.url=jdbc:h2:file:../var/store/h2db;DB_CLOSE_DELAY=-1
database.username=app
database.password=app
diff --git a/server/apps/jpa-app/src/main/resources/META-INF/persistence.xml
b/server/apps/jpa-app/src/main/resources/META-INF/persistence.xml
index e585342d0f..6f8a1aa023 100644
--- a/server/apps/jpa-app/src/main/resources/META-INF/persistence.xml
+++ b/server/apps/jpa-app/src/main/resources/META-INF/persistence.xml
@@ -54,6 +54,7 @@
<class>org.apache.james.mailbox.jpa.mail.model.JPAMailboxAnnotationId</class>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git a/server/apps/jpa-smtp-app/README.adoc
b/server/apps/jpa-smtp-app/README.adoc
index 4264d97efd..5b05c4dea3 100644
--- a/server/apps/jpa-smtp-app/README.adoc
+++ b/server/apps/jpa-smtp-app/README.adoc
@@ -1,6 +1,6 @@
= Guice-JPA SMTP Server How-to
-This server target single node James deployments. By default, the derby
database is used.
+This server target single node James deployments. By default, the H2 database
is used.
This server acts as a Mail Transfer Agent and do not embed the mailbox
component.
diff --git a/server/apps/jpa-smtp-app/pom.xml b/server/apps/jpa-smtp-app/pom.xml
index a8307dab25..4c0d423daa 100644
--- a/server/apps/jpa-smtp-app/pom.xml
+++ b/server/apps/jpa-smtp-app/pom.xml
@@ -148,6 +148,10 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
<dependency>
<groupId>com.linagora</groupId>
<artifactId>logback-elasticsearch-appender</artifactId>
@@ -163,14 +167,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- </dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
@@ -241,7 +237,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <!-- Isolation issues with Derby inMemory database -->
+ <!-- Isolation issues with H2 inMemory database -->
<reuseForks>false</reuseForks>
<!-- Speed up a bit things -->
<forkCount>1C</forkCount>
@@ -297,7 +293,7 @@
<volume>/root/conf</volume>
<!-- Data for ActiveMQ mailQueue -->
<volume>/root/var</volume>
- <!-- Data for derby database -->
+ <!-- Data for H2 database -->
<volume>/var/store</volume>
<volume>/root/glowroot/plugins</volume>
<volume>/root/glowroot/data</volume>
diff --git
a/server/apps/jpa-smtp-app/sample-configuration/james-database.properties
b/server/apps/jpa-smtp-app/sample-configuration/james-database.properties
index 22f2871d1e..83ebfa8e5d 100644
--- a/server/apps/jpa-smtp-app/sample-configuration/james-database.properties
+++ b/server/apps/jpa-smtp-app/sample-configuration/james-database.properties
@@ -20,9 +20,9 @@
# Read
https://james.apache.org/server/config-system.html#james-database.properties
for further details
-# Use derby as default
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:../var/store/derby;create=true
+# Use H2 as default
+database.driverClassName=org.h2.Driver
+database.url=jdbc:h2:file:../var/store/h2db;DB_CLOSE_DELAY=-1
database.username=app
database.password=app
diff --git
a/server/apps/jpa-smtp-app/src/main/resources/META-INF/persistence.xml
b/server/apps/jpa-smtp-app/src/main/resources/META-INF/persistence.xml
index 07931a5f31..5b13376a23 100644
--- a/server/apps/jpa-smtp-app/src/main/resources/META-INF/persistence.xml
+++ b/server/apps/jpa-smtp-app/src/main/resources/META-INF/persistence.xml
@@ -30,6 +30,7 @@
<class>org.apache.james.user.jpa.model.JPAUser</class>
<class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git
a/server/apps/jpa-smtp-app/src/test/java/org/apache/james/mariadb/TestJPAMariaDBConfigurationModule.java
b/server/apps/jpa-smtp-app/src/test/java/org/apache/james/mariadb/TestJPAMariaDBConfigurationModule.java
index 5031af37db..b66b8843b3 100644
---
a/server/apps/jpa-smtp-app/src/test/java/org/apache/james/mariadb/TestJPAMariaDBConfigurationModule.java
+++
b/server/apps/jpa-smtp-app/src/test/java/org/apache/james/mariadb/TestJPAMariaDBConfigurationModule.java
@@ -49,6 +49,7 @@ public class TestJPAMariaDBConfigurationModule extends
AbstractModule {
.driverURL(mariaDBUrl)
.username(MARIA_USERNAME)
.password(MARIA_PASSWORD)
+
.setCustomOpenjpaProperties(java.util.Map.of("openjpa.jdbc.DBDictionary",
"mariadb"))
.build();
}
}
diff --git
a/server/apps/migration/core-data-jpa-to-pg/sample-configuration/james-database.properties
b/server/apps/migration/core-data-jpa-to-pg/sample-configuration/james-database.properties
index fbdcb18ca6..8d794b2d6f 100644
---
a/server/apps/migration/core-data-jpa-to-pg/sample-configuration/james-database.properties
+++
b/server/apps/migration/core-data-jpa-to-pg/sample-configuration/james-database.properties
@@ -20,9 +20,9 @@
# Read
https://james.apache.org/server/config-system.html#james-database.properties
for further details
-# Use derby as default
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:../var/store/derby;create=true
+# Use H2 as default
+database.driverClassName=org.h2.Driver
+database.url=jdbc:h2:file:../var/store/h2db;DB_CLOSE_DELAY=-1
#database.url=${env:DATABASE_URL}
database.username=app
#database.username=${env:DATABASE_USERNAME}
diff --git
a/server/apps/scaling-pulsar-smtp/src/main/resources/META-INF/persistence.xml
b/server/apps/scaling-pulsar-smtp/src/main/resources/META-INF/persistence.xml
index 81253df6a7..22102ac138 100644
---
a/server/apps/scaling-pulsar-smtp/src/main/resources/META-INF/persistence.xml
+++
b/server/apps/scaling-pulsar-smtp/src/main/resources/META-INF/persistence.xml
@@ -29,6 +29,7 @@
<class>org.apache.james.user.jpa.model.JPAUser</class>
<class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git a/server/apps/spring-app/pom.xml b/server/apps/spring-app/pom.xml
index 8bc23bf875..c1cf5d5300 100644
--- a/server/apps/spring-app/pom.xml
+++ b/server/apps/spring-app/pom.xml
@@ -485,18 +485,13 @@
<artifactId>protocols-managesieve</artifactId>
</dependency>
<dependency>
- <groupId>commons-daemon</groupId>
- <artifactId>commons-daemon</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- <scope>runtime</scope>
+ <groupId>commons-daemon</groupId>
+ <artifactId>commons-daemon</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
diff --git
a/server/apps/spring-app/src/main/resources/META-INF/persistence-template.xml
b/server/apps/spring-app/src/main/resources/META-INF/persistence-template.xml
index 128d561d76..88326f4e41 100644
---
a/server/apps/spring-app/src/main/resources/META-INF/persistence-template.xml
+++
b/server/apps/spring-app/src/main/resources/META-INF/persistence-template.xml
@@ -57,6 +57,8 @@
<class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
<properties>
+ <!-- DBDictionary for H2 database -->
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<!-- Create tables on startup -->
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<!-- Create foreign keys on startup -->
diff --git a/server/apps/spring-app/src/main/resources/META-INF/persistence.xml
b/server/apps/spring-app/src/main/resources/META-INF/persistence.xml
index 69659a9eae..043b999b9d 100644
--- a/server/apps/spring-app/src/main/resources/META-INF/persistence.xml
+++ b/server/apps/spring-app/src/main/resources/META-INF/persistence.xml
@@ -50,6 +50,7 @@
<class>org.apache.james.mailbox.jpa.quota.model.JpaCurrentQuota</class>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git
a/server/apps/spring-app/src/main/resources/james-database.properties
b/server/apps/spring-app/src/main/resources/james-database.properties
index bc90988643..b8faf21f61 100644
--- a/server/apps/spring-app/src/main/resources/james-database.properties
+++ b/server/apps/spring-app/src/main/resources/james-database.properties
@@ -20,9 +20,9 @@
# See http://james.apache.org/server/3/config.html for usage
-# Use derby as default
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:../var/store/derby;create=true
+# Use H2 as default
+database.driverClassName=org.h2.Driver
+database.url=jdbc:h2:file:../var/store/h2db;DB_CLOSE_DELAY=-1
database.username=app
database.password=app
diff --git a/server/apps/spring-app/src/main/resources/sqlResources.xml
b/server/apps/spring-app/src/main/resources/sqlResources.xml
index 787890f8b8..f948b40e83 100644
--- a/server/apps/spring-app/src/main/resources/sqlResources.xml
+++ b/server/apps/spring-app/src/main/resources/sqlResources.xml
@@ -44,7 +44,7 @@
<dbMatcher db="mssql" databaseProductName="microsoft sql server"/>
<dbMatcher db="oracle" databaseProductName="oracle.*"/>
<dbMatcher db="mysql" databaseProductName="my.*"/>
- <dbMatcher db="derby" databaseProductName="derby.*"/>
+ <dbMatcher db="h2" databaseProductName="h2.*"/>
<dbMatcher db="postgresql" databaseProductName="postgres.*"/>
<dbMatcher db="hsqldb" databaseProductName="hsql.*"/>
<dbMatcher db="sapdb" databaseProductName="sap.*"/>
@@ -88,8 +88,8 @@
<dbOption db="oracle" name="getAttributes" value="useBlob"/>
<dbOption db="mysql" name="getBody" value="useBytes"/>
<dbOption db="mysql" name="getAttributes" value="useBytes"/>
- <dbOption db="derby" name="getBody" value="useBytes"/>
- <dbOption db="derby" name="getAttributes" value="useBytes"/>
+ <dbOption db="h2" name="getBody" value="useBytes"/>
+ <dbOption db="h2" name="getAttributes" value="useBytes"/>
<dbOption db="postgresql" name="getBody" value="useBytes"/>
<dbOption db="postgresql" name="getAttributes" value="useBytes"/>
<dbOption db="sapdb" name="getBody" value="useBytes"/>
@@ -152,7 +152,7 @@
<sql name="retrieveMessageBodySizeSQL" db="oracle">SELECT
dbms_lob.getlength(message_body) FROM ${table} WHERE message_name = ? AND
repository_name = ?</sql>
<sql name="retrieveMessageBodySizeSQL" db="db2">SELECT
length(message_body) FROM ${table} WHERE message_name = ? AND repository_name =
?</sql>
<sql name="retrieveMessageBodySizeSQL" db="ingres">SELECT
length(message_body) FROM ${table} WHERE message_name = ? AND repository_name =
?</sql>
- <sql name="retrieveMessageBodySizeSQL" db="derby">SELECT
length(message_body) FROM ${table} WHERE message_name = ? AND repository_name =
?</sql>
+ <sql name="retrieveMessageBodySizeSQL" db="h2">SELECT
length(message_body) FROM ${table} WHERE message_name = ? AND repository_name =
?</sql>
<!-- Statements used to delete a message stored in this repository. -->
<sql name="removeMessageSQL">DELETE FROM ${table} WHERE message_name =
? AND repository_name = ?</sql>
@@ -316,7 +316,7 @@
message_attributes LONG BYTE ,
)
</sql>
- <sql name="createTable" db="derby">
+ <sql name="createTable" db="h2">
CREATE TABLE ${table} (
message_name varchar (200) NOT NULL,
repository_name varchar (255) NOT NULL,
@@ -408,7 +408,7 @@
network varchar (255) NOT NULL
)
</sql>
- <sql name="createNetworkWhiteListTable" db="derby">
+ <sql name="createNetworkWhiteListTable" db="h2">
CREATE TABLE networkWhitelist (
localUser varchar (64) NOT NULL,
localHost varchar (255) NOT NULL,
@@ -531,7 +531,7 @@
PRIMARY KEY (ipaddress,sender,recip)
)
</sql>
- <sql name="createGreyListTable" db="derby">
+ <sql name="createGreyListTable" db="h2">
CREATE TABLE greylist (
ipaddress varchar (20) NOT NULL,
sender varchar (255) NOT NULL,
diff --git a/server/container/guice/jpa-common/pom.xml
b/server/container/guice/jpa-common/pom.xml
index 78b253f7a8..ce9b0d2e21 100644
--- a/server/container/guice/jpa-common/pom.xml
+++ b/server/container/guice/jpa-common/pom.xml
@@ -60,13 +60,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/server/container/guice/jpa-common/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java
b/server/container/guice/jpa-common/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java
index bb734d1974..f4cc7085dc 100644
---
a/server/container/guice/jpa-common/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java
+++
b/server/container/guice/jpa-common/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java
@@ -82,7 +82,19 @@ public class JPAEntityManagerModule extends AbstractModule {
Configuration dataSource =
propertiesProvider.getConfiguration("james-database");
Map<String, String> openjpaProperties = getKeysForPrefix(dataSource,
"openjpa", false);
+ // Remove default JPA properties that are already set via the builder
+ openjpaProperties.remove(JPAConfiguration.JPA_CONNECTION_DRIVER_NAME);
+ openjpaProperties.remove(JPAConfiguration.JPA_CONNECTION_URL);
+ openjpaProperties.remove(JPAConfiguration.JPA_MULTITHREADED);
+ openjpaProperties.remove(JPAConfiguration.JPA_CONNECTION_USERNAME);
+ openjpaProperties.remove(JPAConfiguration.JPA_CONNECTION_PASSWORD);
+
Map<String, String> datasourceProperties =
getKeysForPrefix(dataSource, "datasource", true);
+ // Remove default datasource properties that are already set via the
builder
+ datasourceProperties.remove("testOnBorrow");
+ datasourceProperties.remove("validationQueryTimeoutSec");
+ datasourceProperties.remove("validationQuery");
+ datasourceProperties.remove("maxTotal");
return JPAConfiguration.builder()
.driverName(dataSource.getString("database.driverClassName"))
diff --git
a/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModule.java
b/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModule.java
index 61e8751699..3fe98275e2 100644
---
a/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModule.java
+++
b/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModule.java
@@ -28,8 +28,8 @@ import com.google.inject.Provides;
public class TestJPAConfigurationModule extends AbstractModule {
- private static final String JDBC_EMBEDDED_URL =
"jdbc:derby:memory:mailboxintegration;create=true";
- private static final String JDBC_EMBEDDED_DRIVER =
org.apache.derby.jdbc.EmbeddedDriver.class.getName();
+ private static final String JDBC_EMBEDDED_URL =
"jdbc:h2:mem:mailboxintegration;DB_CLOSE_DELAY=-1";
+ private static final String JDBC_EMBEDDED_DRIVER =
org.h2.Driver.class.getName();
@Override
protected void configure() {
diff --git
a/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
b/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
index 960e26ca84..a8542b2500 100644
---
a/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
+++
b/server/container/guice/jpa-common/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
@@ -19,7 +19,6 @@
package org.apache.james;
-import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -49,7 +48,7 @@ public interface TestJPAConfigurationModuleWithSqlValidation {
@Override
protected void configure() {
- setupAuthenticationOnDerby();
+ setupDatabaseAuthentication();
}
@Provides
@@ -61,30 +60,11 @@ public interface
TestJPAConfigurationModuleWithSqlValidation {
.build();
}
- private void setupAuthenticationOnDerby() {
+ private void setupDatabaseAuthentication() {
try (Connection conn =
DriverManager.getConnection(JDBC_EMBEDDED_URL, DATABASE_USERNAME,
DATABASE_PASSWORD)) {
- // Setting and Confirming requireAuthentication
- setDerbyProperty(conn,
"derby.connection.requireAuthentication", "true");
-
- // Setting authentication scheme and username password to Derby
- setDerbyProperty(conn, "derby.authentication.provider",
"BUILTIN");
- setDerbyProperty(conn, "derby.user." + DATABASE_USERNAME + "",
DATABASE_PASSWORD);
- setDerbyProperty(conn, "derby.database.propertiesOnly",
"true");
-
- // Setting default connection mode to no access to restrict
accesses without authentication information
- setDerbyProperty(conn, "derby.database.defaultConnectionMode",
"noAccess");
- setDerbyProperty(conn, "derby.database.fullAccessUsers",
DATABASE_USERNAME);
- setDerbyProperty(conn, "derby.database.propertiesOnly",
"false");
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void setDerbyProperty(Connection conn, String key, String
value) {
- try (CallableStatement call = conn.prepareCall("CALL
SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)")) {
- call.setString(1, key);
- call.setString(2, value);
- call.execute();
+ // H2 authentication is handled through the connection URL and
credentials
+ // No additional setup required as H2 accepts user/password in
connection parameters
+ // The database will be created with the provided credentials
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -93,9 +73,9 @@ public interface TestJPAConfigurationModuleWithSqlValidation {
String DATABASE_USERNAME = "james";
String DATABASE_PASSWORD = "james-secret";
- String JDBC_EMBEDDED_URL =
"jdbc:derby:memory:mailboxintegration;create=true";
- String JDBC_EMBEDDED_DRIVER =
org.apache.derby.jdbc.EmbeddedDriver.class.getName();
- String VALIDATION_SQL_QUERY = "VALUES 1";
+ String JDBC_EMBEDDED_URL =
"jdbc:h2:mem:mailboxintegration;DB_CLOSE_DELAY=-1";
+ String JDBC_EMBEDDED_DRIVER = org.h2.Driver.class.getName();
+ String VALIDATION_SQL_QUERY = "SELECT 1";
static JPAConfiguration.ReadyToBuild jpaConfigurationBuilder() {
return JPAConfiguration.builder()
diff --git a/server/data/data-jpa/pom.xml b/server/data/data-jpa/pom.xml
index e2c10a24bc..6ba6f2e718 100644
--- a/server/data/data-jpa/pom.xml
+++ b/server/data/data-jpa/pom.xml
@@ -104,6 +104,11 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
@@ -133,16 +138,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
diff --git
a/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java
b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java
index 394513e016..c547b0c933 100644
---
a/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java
+++
b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java
@@ -19,7 +19,9 @@
package org.apache.james.sieve.jpa.model;
+import java.time.Instant;
import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
import java.util.Objects;
import java.util.UUID;
@@ -60,7 +62,7 @@ public class JPASieveScript {
private String scriptContent;
private long scriptSize;
private boolean isActive;
- private OffsetDateTime activationDateTime;
+ private Instant activationDateTime;
public Builder username(String username) {
Preconditions.checkNotNull(username);
@@ -89,7 +91,7 @@ public class JPASieveScript {
public JPASieveScript build() {
Preconditions.checkState(StringUtils.isNotBlank(username),
"'username' is mandatory");
Preconditions.checkState(StringUtils.isNotBlank(scriptName),
"'scriptName' is mandatory");
- this.activationDateTime = isActive ? OffsetDateTime.now() : null;
+ this.activationDateTime = isActive ? Instant.now() : null;
return new JPASieveScript(username, scriptName, scriptContent,
scriptSize, isActive, activationDateTime);
}
}
@@ -113,7 +115,7 @@ public class JPASieveScript {
private boolean isActive;
@Column(name = "ACTIVATION_DATE_TIME")
- private OffsetDateTime activationDateTime;
+ private Instant activationDateTime;
/**
* @deprecated enhancement only
@@ -122,7 +124,7 @@ public class JPASieveScript {
protected JPASieveScript() {
}
- private JPASieveScript(String username, String scriptName, String
scriptContent, long scriptSize, boolean isActive, OffsetDateTime
activationDateTime) {
+ private JPASieveScript(String username, String scriptName, String
scriptContent, long scriptSize, boolean isActive, Instant activationDateTime) {
this.username = username;
this.scriptName = scriptName;
this.scriptContent = scriptContent;
@@ -152,12 +154,12 @@ public class JPASieveScript {
}
public OffsetDateTime getActivationDateTime() {
- return activationDateTime;
+ return activationDateTime != null ?
activationDateTime.atOffset(ZoneOffset.UTC) : null;
}
public void activate() {
this.isActive = true;
- this.activationDateTime = OffsetDateTime.now();
+ this.activationDateTime = Instant.now();
}
public void deactivate() {
diff --git a/server/data/data-jpa/src/test/resources/persistence.xml
b/server/data/data-jpa/src/test/resources/persistence.xml
index 9b440351c7..5eb7693640 100644
--- a/server/data/data-jpa/src/test/resources/persistence.xml
+++ b/server/data/data-jpa/src/test/resources/persistence.xml
@@ -36,6 +36,7 @@
<class>org.apache.james.sieve.jpa.model.JPASieveScript</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
+ <property name="openjpa.jdbc.DBDictionary" value="h2"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
diff --git
a/src/adr/0036-against-use-of-conditional-statements-in-guice-modules.md
b/src/adr/0036-against-use-of-conditional-statements-in-guice-modules.md
index 9416a4a64a..510449e565 100644
--- a/src/adr/0036-against-use-of-conditional-statements-in-guice-modules.md
+++ b/src/adr/0036-against-use-of-conditional-statements-in-guice-modules.md
@@ -38,8 +38,8 @@ Here is the list of products we provide:
ElasticSearch for search, RabbitMQ for messaging, and ObjectStorage for blobs.
- Cassandra: An implementation step toward Distributed James. It does not
include messaging and ObjectStorage and
should not be run in a cluster way but is still relevant for good performance.
- - JPA: A JPA and Lucene based implementation of James. Only Derby driver is
currently supported.
- - JPA with SMTP only using Derby: A minimalist SMTP server based on JPA
storage technology and Derby driver
+ - JPA: A JPA and Lucene based implementation of James. H2 driver is used by
default.
+ - JPA with SMTP only using H2: A minimalist SMTP server based on JPA storage
technology with H2 driver as default
- JPA with SMTP only using MariaDB: A minimalist SMTP server based on JPA
storage technology and MariaDB driver
Some components however do have several implementations a user can choose from
in a given product. This is the case for:
diff --git a/src/site/xdoc/download.xml b/src/site/xdoc/download.xml
index 956ab08067..8dc8564f93 100644
--- a/src/site/xdoc/download.xml
+++ b/src/site/xdoc/download.xml
@@ -86,7 +86,7 @@
<p><b>JPA James server</b> (legacy):</p>
<p>This artifact packages the JPA James server, a simple distribution
with zero external dependencies
- (defaults to an embedded Derby database) that can be configured with
an external SQL database.</p>
+ (defaults to an embedded H2 database) that can be configured with an
external SQL database.</p>
<li>Binary (ZIP Format) for the JPA James server:
<a
href="https://www.apache.org/dyn/closer.lua/james/server/3.9.0/james-server-jpa-guice.zip">james-server-jpa-guice.zip</a>
@@ -117,7 +117,7 @@
<p><b>JPA James server</b>:</p>
<p>This artifact packages the JPA James server, a simple distribution
with zero external dependencies
- (defaults to an embedded Derby database) that can be configured with
an external SQL database.</p>
+ (defaults to an embedded H2 database) that can be configured with an
external SQL database.</p>
<li>Binary (ZIP Format) for the JPA James server:
<a
href="https://www.apache.org/dyn/closer.lua/james/server/3.7.6/james-server-jpa-guice.zip">james-server-jpa-guice.zip</a>
diff --git a/src/site/xdoc/server/config-spring-jpa-postgres.xml
b/src/site/xdoc/server/config-spring-jpa-postgres.xml
index 9965ac5e34..ad5d9a3906 100644
--- a/src/site/xdoc/server/config-spring-jpa-postgres.xml
+++ b/src/site/xdoc/server/config-spring-jpa-postgres.xml
@@ -31,7 +31,7 @@
</section>
<section name="Current Supported Relational Database">
- <p>James supports Derby as a default database, you do not need to do any
additional configuration if you are using Derby</p>
+ <p>James supports H2 as a default database, you do not need to do any
additional configuration if you are using H2</p>
</section>
<section name="Spring JPA With Postgres Configuration">
diff --git a/src/site/xdoc/server/dev.xml b/src/site/xdoc/server/dev.xml
index dd146480dd..ba097167e8 100644
--- a/src/site/xdoc/server/dev.xml
+++ b/src/site/xdoc/server/dev.xml
@@ -80,7 +80,7 @@
<a href="images/uml/org.apache.james-package-detail_large.png"
id="arch-img-id"><img
src="images/uml/org.apache.james-package-detail_small.png"/></a>
<p><a href="images/uml/org.apache.james-package-detail_large.png"
id="arch-txt-id">Click to enlarge image</a></p>
- <p>James uses many other components: Spring, ActiveMQ, OpenJPA, Netty,
Jackrabbit, Derby...</p>
+ <p>James uses many other components: Spring, ActiveMQ, OpenJPA, Netty,
Jackrabbit, H2...</p>
<p>The modules can be classified into 3 categories:</p>
<ul>
diff --git a/src/site/xdoc/server/install.xml b/src/site/xdoc/server/install.xml
index 35b060c4cb..0408da5d65 100644
--- a/src/site/xdoc/server/install.xml
+++ b/src/site/xdoc/server/install.xml
@@ -63,7 +63,7 @@
<p>James is configured to run with 512 MB RAM (-Xmx512M in the bat/sh)
available, but may need more or
less depending on the load. With the default configuration, JVM can use
until 512M (It does not mean it will do).
It really depends on your traffic, and also which mailbox you will use
(you can save much memory
- if you don't use the default embedded derby database but an external
database of your choice).
+ if you don't use the default embedded H2 database but an external
database of your choice).
Work is still done to minimize the needed memory.
</p>
diff --git a/src/site/xdoc/server/monitor-folders.xml
b/src/site/xdoc/server/monitor-folders.xml
index b9cda634c8..3bfbede3d8 100644
--- a/src/site/xdoc/server/monitor-folders.xml
+++ b/src/site/xdoc/server/monitor-folders.xml
@@ -39,7 +39,7 @@ mail
+-spam
store
-+-derby
++-h2db
+-jackrabbit
+-activemq
+-brokers
@@ -65,8 +65,8 @@ store
var/mail can be address-error, error, relay-denied, spam</p>
<p>The store folder contains the files related to database,
activemq,... needed by James.
- James Server default settings comes with a embedded Derby database
that stores the
- users, domains and mailboxes (the user mails) (see store/derby
folder).</p>
+ James Server default settings comes with a embedded H2 database that
stores the
+ users, domains and mailboxes (the user mails) (see store/h2db
folder).</p>
<p>Of course, if you changed database.properties and still use a
database for the mailboxes,
you will have to look for the users, domains and mailboxes in your
database, whatever,
diff --git a/src/site/xdoc/server/packaging.xml
b/src/site/xdoc/server/packaging.xml
index 6a0abc0852..8a6fd5a969 100644
--- a/src/site/xdoc/server/packaging.xml
+++ b/src/site/xdoc/server/packaging.xml
@@ -44,7 +44,7 @@
<li><a
href="https://github.com/apache/james-project/tree/master/server/apps/distributed-app">
Distributed: cassandra-rabbitmq-guice</a>: Ships a James
server storing emails in Cassandra and index them in OpenSearch targeting multi
node deployments. S3 is used to store blobs. RabbitMQ is used for inter-node
messaging. Optional support for LDAP authentication.</li>
<li><a
href="https://github.com/apache/james-project/tree/master/server/apps/jpa-app">
- Jpa-Guice</a>: Ships a James server storing emails in a
SQL database (derby by default) accessed with JPA and Lucene to index emails
and targets single node deployment.</li>
+ Jpa-Guice</a>: Ships a James server storing emails in a
SQL database (H2 by default) accessed with JPA and Lucene to index emails and
targets single node deployment.</li>
<li><a
href="https://github.com/apache/james-project/tree/master/server/apps/jpa-smtp-app">
Jpa-Smtp</a>: A tiny SMTP server shiped without mailbox,
using SQL database to store data, accessed by JPA.</li>
</ul>
@@ -241,7 +241,7 @@
<tr>
<td>apache/james:jpa-3.9.0</td>
<td>Single node</td>
- <td>Embedded Derby database (JPA, SQL)</td>
+ <td>Embedded H2 database (JPA, SQL)</td>
<td>Not applicable</td>
<td>In VM</td>
<td>Index Lucene on the filesystem</td>
@@ -250,7 +250,7 @@
<tr>
<td>apache/james:demo-3.9.0</td>
<td>Pre-provisioned Single node instance to ease
project discovery</td>
- <td>Embedded Derby database (JPA, SQL)</td>
+ <td>Embedded H2 database (JPA, SQL)</td>
<td>Not applicable</td>
<td>In VM</td>
<td>Index Lucene on the filesystem</td>
diff --git a/src/site/xdoc/server/quick-start.xml
b/src/site/xdoc/server/quick-start.xml
index 9719bc173d..c0722b52a8 100644
--- a/src/site/xdoc/server/quick-start.xml
+++ b/src/site/xdoc/server/quick-start.xml
@@ -108,7 +108,7 @@ usersrepository.xml
wrapper.xml
lib folder (for your additional jar, e.g. JDBC drviers,...)
-James is packaged with virtual hosting enabled, JPA (Derby database) storage
for the mails, users, and domains.
+James is packaged with virtual hosting enabled, JPA (H2 database) storage for
the mails, users, and domains.
On SMTP (see smtpserver.xml config)
* authRequired is true by default, so you can safely deploy James on the
Internet (it won't be an open relay).
* verifyIdentity is true by default (you can only send mails with a FROM
being the authenticated user).
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]