[jira] [Updated] (OPENJPA-2687) a special DatabaseProductVersion cause a wrong DBDicitionary

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jira] [Updated] (OPENJPA-2687) a special DatabaseProductVersion cause a wrong DBDicitionary

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/OPENJPA-2687?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

zephyr.yi updated OPENJPA-2687:
-------------------------------
    Affects Version/s: 3.0.0
                       2.4.1

> a special DatabaseProductVersion cause a wrong DBDicitionary
> ------------------------------------------------------------
>
>                 Key: OPENJPA-2687
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2687
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, jpa
>    Affects Versions: 2.4.1, 2.4.2, 3.0.0
>            Reporter: zephyr.yi
>            Priority: Minor
>         Attachments: DBDicitionaryFactory.patch
>
>
> 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:
> {code:java}
> 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
> {code}
> 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
> {code:java}
>     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;
>         }
>     }
> {code}
> 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



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Loading...