After upgrade to 4.0.2, OpenFire cant connect to MySQL

Hi all!

I’m running Openfire on Arch Linux and I recently updated from version 4.0.1 to 4.0.2 and all of a sudden, OpenFire cant connect to the mysql database.

Here is the error log

2016.03.26 11:47:40 org.jivesoftware.util.JiveProperties - java.lang.NullPointerException
  at java.util.Hashtable.put(Hashtable.java:514)
  at java.util.Properties.setProperty(Properties.java:161)
  at org.jivesoftware.database.DefaultConnectionProvider.start(DefaultConnectionProvider.java:106)
  at org.jivesoftware.database.DbConnectionManager.setConnectionProvider(DbConnectionManager.java:598)
  at org.jivesoftware.database.DbConnectionManager.ensureConnectionProvider(DbConnectionManager.java:104)
  at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:121)
  at org.jivesoftware.util.JiveProperties.loadProperties(JiveProperties.java:357)
  at org.jivesoftware.util.JiveProperties.init(JiveProperties.java:88)
  at org.jivesoftware.util.JiveProperties.getInstance(JiveProperties.java:66)
  at org.jivesoftware.util.JiveGlobals.getProperty(JiveGlobals.java:557)
  at org.jivesoftware.util.cache.CacheFactory.<clinit>(CacheFactory.java:94)
  at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:332)
  at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:440)
  at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:169)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  at java.lang.Class.newInstance(Class.java:383)
  at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:105)
  at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56)
2016.03.26 11:47:40 org.jivesoftware.util.log.util.CommonsLogFactory - Prototype
java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:926)
  at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1748)
  at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1288)
  at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2506)
  at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2539)
  at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2321)
  at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:832)
  at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
  at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:417)
  at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)
  at java.sql.DriverManager.getConnection(DriverManager.java:571)
  at java.sql.DriverManager.getConnection(DriverManager.java:187)
  at org.logicalcobwebs.proxool.DefaultConnectionBuilder.buildConnection(DefaultConnectionBuilder.java:39)
  at org.logicalcobwebs.proxool.Prototyper.buildConnection(Prototyper.java:159)
  at org.logicalcobwebs.proxool.Prototyper.sweep(Prototyper.java:102)
  at org.logicalcobwebs.proxool.PrototyperThread.run(PrototyperThread.java:44)
2016.03.26 11:47:43 org.jivesoftware.openfire.XMPPServer - Database could not be accessed
java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 retries. The exception from the last attempt is as follows: java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
  at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:156)
  at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:724)
  at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:448)
  at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:169)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  at java.lang.Class.newInstance(Class.java:383)
  at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:105)
  at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56)

The error log indicates that OpenFire is trying to connect with a blank user name and no password. This is not what OpenFire is configured with obviously. I’m assuming the root cause is indicated by the first error message indicating a NullPointerException.

Does anyone have any idea whats wrong here? I tried downgrading to 4.0.1 but the problem persists on that version now as well.

Thanks!

Was conf/openfire.xml modified during the upgrade? It should contain the username and password.

Not sure if it was modified but after studying the error logs further it seems like it was attempting to connect to the database using the hashed username and password. I changed the credentials to their cleartext equivalents in openfire.xml and now it works fine. However, the credentials are now stored in plaintext. So it seems to me like something went wrong during the upgrade where it did handle the one-way hashed credentials correctly somehow.

i think i have solution for this mess.

  1. Always backup your openfire before perform update, specially openfire.xml [configuration file]

  2. After Update your Openfire to newer version, you can use your old openfire.xml file. This work for me.

  3. In case forget/not backup your existing openfire.xml, you can:

— a. reinstall previous version of openfire then keep its configuration file / openfire.xml . or

— b. modify your new openfire.xml file with exact value of your my sql database. [[ this kinda tricky and not easy to implement]]

pray…