Kohei Nozaki's blog 

Configuring Apache James to use PostgreSQL as the backend


Posted on Sunday Apr 19, 2015 at 09:37PM in Technology


UPDATE: I’m running into a strange problem of using PostgreSQL as backend with Thunderbird. I recommend to use an other database as the backend at the moment. http://www.mail-archive.com/server-user%40james.apache.org/msg14715.html

UPDATE2: I created a patch to solve the issue and it seems fine. for detail and download the patch see: https://issues.apache.org/jira/browse/MAILBOX-228

I have been used Apache James with Embedded Derby, but its CPU/IO consumption is increasing day by day. I’m not sure where is the bottleneck but I decided to move to PostgreSQL as its backend anyway.

  1. Put JDBC driver (I used postgresql-9.3-1100.jdbc41.jar) into $JAMES_HOME/conf/lib

  2. Create james-database.properties from template, and put it into $JAMES_HOME/conf as follows

    database.driverClassName=org.postgresql.Driver
    database.url=jdbc:postgresql://127.0.0.1:5432/james
    database.username=james
    database.password=***
    
    vendorAdapter.database=POSTGRESQL
    
    openjpa.streaming=true
  3. Restart James instance

  4. Create domains, addresses and aliases:

    ./james-cli.sh -h localhost -p 9999 adddomain example.org
    ./james-cli.sh -h localhost -p 9999 adduser kyle@example.org ***
    ./james-cli.sh -p 9999 -h localhost addaddressmapping postmaster example.org kyle@example.org

Note

This guide claims that setting standard_conforming_strings=off is needed, but I guess this issue may address this problem, so I don’t use this setting at the moment. my James installation is shipped with openjpa-2.2.1.jar and the issue was fixed in 2.2.0.