Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2687

a special DatabaseProductVersion cause a wrong DBDicitionary

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.4.1, 2.4.2, 3.0.0
    • Fix Version/s: None
    • Component/s: jdbc, jpa
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      mysql server info:
      ********************************************************
      Welcome to the MySQL monitor. Commands end with ; or \g.
      Server version: 5.6.28-cdb20160902-log 20160902
      ********************************************************

      notice that this mysql was mdified and the ProductVersion has set "5.6.28-cdb20160902-log"

      after connect this database, a exception throw:

      org.apache.oozie.service.ServiceException: E0103: Could not load service classes, The database product "MySQL", version "5.6.28-cdb20160902-log" is not officially supported.
      	at org.apache.oozie.service.Services.loadServices(Services.java:309)
      	at org.apache.oozie.service.Services.init(Services.java:213)
      	at org.apache.oozie.servlet.ServicesLoader.contextInitialized(ServicesLoader.java:46)
      	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4276)
      	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4779)
      	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:803)
      	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:780)
      	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
      	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:676)
      	at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:602)
      	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:503)
      	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
      	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:325)
      	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
      	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1069)
      	at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
      	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
      	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
      	at org.apache.catalina.core.StandardService.start(StandardService.java:525)
      	at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
      	at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
      	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
      Caused by: <openjpa-2.4.2-r422266:1777108 fatal general error> org.apache.openjpa.persistence.PersistenceException: The database product "MySQL", version "5.6.28-cdb20160902-log" is not officially supported.
      	at org.apache.openjpa.jdbc.sql.DB2Dictionary.connectedConfiguration(DB2Dictionary.java:319)
      	at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:208)
      	at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:106)
             at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:603)
      	at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1520)
      	at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:533)
      	at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:458)
      	at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:121)
      	at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
      	at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
      	at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:967)
      	at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:958)
      	at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:642)
      	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:202)
      	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:154)
      	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:226)
      	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:153)
      	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:59)
      	at org.apache.oozie.service.JPAService.getEntityManager(JPAService.java:514)
      	at org.apache.oozie.service.JPAService.init(JPAService.java:215)
      	at org.apache.oozie.service.Services.setServiceInternal(Services.java:386)
      	at org.apache.oozie.service.Services.setService(Services.java:372)
      	at org.apache.oozie.service.Services.loadServices(Services.java:305)
      	... 26 more
      

      then programe stopped.

      trace this exception,I found that DBDictionaryFactory create a DB2Dictionary for mysql connection! Something wrong.

      then check code, there maybe has a bug
      openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java
      line93~103

          DatabaseMetaData meta = conn.getMetaData();
          String dclass = dictionaryClassForString(meta.getDatabaseProductName(), conf);  
          Log log = conf.getLog(JDBCConfiguration.LOG_JDBC);
          if (dclass == null)
          dclass = dictionaryClassForString(getProtocol(meta.getURL()), conf);
          if (dclass != null && dclass.contains("MySQL")) {
      		// MariaDB returns "MySQL" for product name, need to verify by looking at product version.
              final String checkMariaDB = dictionaryClassForString(meta.getDatabaseProductVersion(), conf);
              if (checkMariaDB != null) {
                  dclass = checkMariaDB;
              }
          }
      

      if find string dclass contains "mysql", use DatabaseProductVersion to check MariaDB because mariadb contatin "mariadb" string in its DatabaseProductVersion.

      In my case, DatabaseProductVersion didnot contain "mariadb" string ,but has a string "db2", so after line 100 executed, the
      checkMariaDB=org.apache.openjpa.jdbc.sql.DB2Dicitionary
      after this, a DB2Dicitionary created for mysql connection

      Is there should be check the checkMariaDB is equal the MariaDBDictionary,class.getName()?

      attach a patch for this bug fix

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zephyryi zephyr.yi
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: