Issue when restart Openfire server after setup Openfire using MySQL with UTF-8 encode via a fresh installation

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 :slight_smile:

Basic info:

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;amp;characterEncoding=UTF-8&amp;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; => &amp;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&amp;characterEncoding=UTF-8&amp;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!

Thanks for detailed report. I have filed this as https://issues.igniterealtime.org/browse/OF-1682

1 Like

A fix for this issue will be available in Openfire 4.4.0. The change has just been committed. Would someone be so kind as to test it?

Hello @guus,
I just updated my local OF and reinstalled it (mvn verify).
I haven’t encountered this issue again, so it seems the correction is working as expected :sunny:

2 Likes

Excellent! Thanks for testing!