Uploaded image for project: 'Apache Fineract'
  1. Apache Fineract
  2. FINERACT-890

Custom slf4j integrated logger for the (optional!) MySQL JDBC driver support in Fineract

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.6.0
    • None

    Description

      While working on FINERACT-762, I've stumbled upon:

      Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Unable to load class for logger 'com.mysql.jdbc.log.StandardLogger'
      	at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:589)
      	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:575)
      	at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
      	at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:203)
      	... 161 more
      Caused by: java.sql.SQLException: Unable to load class for logger 'com.mysql.jdbc.log.StandardLogger'
      	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
      	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
      	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
      	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
      	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
      	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:85)
      	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:452)
      	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
      	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
      	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
      	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354)
      	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
      	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
      	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)
      	... 168 more
      Caused by: com.mysql.cj.exceptions.WrongArgumentException: Unable to load class for logger 'com.mysql.jdbc.log.StandardLogger'
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
      	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
      	at com.mysql.cj.log.LogFactory.getLogger(LogFactory.java:77)
      	at com.mysql.cj.CoreSession.<init>(CoreSession.java:95)
      	at com.mysql.cj.NativeSession.<init>(NativeSession.java:131)
      	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:402)
      	... 175 more
      Caused by: java.lang.ClassNotFoundException: com.mysql.cj.log.com.mysql.jdbc.log.StandardLogger
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:264)
      	at com.mysql.cj.log.LogFactory.getLogger(LogFactory.java:70)
      	... 178 more

      This seems to be due to us setting the Hikari DataSource logger property to com.mysql.jdbc.log.StandardLogger, in both org.apache.fineract.infrastructure.core.service.TomcatJdbcDataSourcePerTenantService and META-INF/spring/hikariDataSource.xml.

      That classname seems to be wrong (outdated?), at least for the latest mysql-connector-java version 8.0.19.

      According to https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html, that's the default anyway, so I'll just comment it out, for now.

      What I think we really should be doing later is implement that it so that instead of spewing to STDERR, it logs correctly (bridged) via slf4j API.

      Attachments

        Issue Links

          Activity

            People

              ptuomola Petri Tuomola
              vorburger Michael Vorburger
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: