Hello,
I recently experienced an issue when setup Openfire to use MySQL with UTF-8 encode via a fresh installation. Fortunately, this problem can be manually fix by editing the /etc/openfire/openfire.xml configuration file. But I wish it will be a better way to solve this problem 
Basic info:
- Openfire version installed, which platform and which Java JRE version using
- Openfire version: 4.3.1
- Platform: Ubuntu Linux 18.10
- Java JRE version: 8 (
openjdk-8-jre-headlesspackage installed viaapt, before openfire installation)
- How was openfire installed
- Download https://github.com/igniterealtime/Openfire/releases/download/v4.3.1/openfire_4.3.1_all.deb
- Install via command
# dpkg -i openfire_4.3.1_all.deb
Detail:
I freshly installed the latest openfire on my Ubuntu machine. I followed the document (http://download.igniterealtime.org/openfire/docs/latest/documentation/database.html#mysql) to setup database configuration in web interface (http://localhost:9090), and I noticed that it mentions the Character Encoding Issues. So I setup database settings like this:
- driver:
com.mysql.jdbc.Driver - server:
jdbc:mysql://127.0.0.1:3306/openfire?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
After finishing the setup, openfire will work fine until I restart the openfire server.
I end up figure out that in /etc/openfire/openfire.xml, the database tag is:
<database>
<defaultProvider>
<driver>com.mysql.jdbc.Driver</driver>
<serverURL>jdbc:mysql://127.0.0.1:3306/openfire?useUnicode=true&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8</serverURL>
<username encrypted="true">some_secret</username>
<password encrypted="true">some_secret</password>
<testSQL>select 1</testSQL>
<testBeforeUse>false</testBeforeUse>
<testAfterUse>false</testAfterUse>
<testTimeout>500</testTimeout>
<timeBetweenEvictionRuns>30000</timeBetweenEvictionRuns>
<minIdleTime>900000</minIdleTime>
<maxWaitTime>500</maxWaitTime>
<minConnections>5</minConnections>
<maxConnections>25</maxConnections>
<connectionTimeout>1.0</connectionTimeout>
</defaultProvider>
</database>
Notice the content of the <serverURL>, it seems that the & character has been escaped twice (& => & => &amp;) during the web interface put the database settings into openfire.xml, which later causes openfire server cannot (re)start correctly.
Fortunately, the problem can be manually fix.
After manually changing the serverURL tag in /etc/openfire/openfire.xml to:
<serverURL>jdbc:mysql://127.0.0.1:3306/openfire?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8</serverURL>
and then restarting openfire server, everything was work fine.
all.log
Here is the /var/log/openfire/all.log file (https://pastebin.com/GCbHT2Dr) when restarting openfire server failed. Hope this help. Thanks!
