OpenJPA
  1. OpenJPA
  2. OPENJPA-2407

Errors using MySql Cluster not present using HSqlDb (build-time enhancement and executing query)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Invalid
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: Enhance
    • Labels:
      None
    • Environment:
      Windows 8 using MySql Cluster

      Description

      Hi,

      I'm seeing some problems when my persistence.xml is populated with details for MySql Cluster - but when I work against HSqlDb everything is working great.

      First issue during build-time enhancement:
      I get the following even though I don't have any @Embeddables in my code
      [openjpac] 407 testdb ERROR [main] openjpa.Enhance - The identity field defined in the code.shared.DataBean Embeddable is not supported.

      Someone else has also encountered this issue: http://stackoverflow.com/questions/16619860/openjpa-enhance-the-identity-field-defined-in-the-0-embeddable-is-not-suppo

      Second issue at runtime:
      During the second invocation of a method that should return everything from a table I get the following stacktrace:
      1797 testdb TRACE [main] openjpa.jdbc.JDBC - <t 488448102, conn 0> [1 ms] close
      <openjpa-2.2.2-r422266:1468616 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null
      at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:625)
      at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:682)
      at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1529)
      at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:124)
      at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:280)
      at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
      at test.OpenJpaTest.findAll(OpenJpaTest.java:60)
      at test.OpenJpaTest.findAllAndAssertSizeOfOne(OpenJpaTest.java:65)
      at test.OpenJpaTest.test(OpenJpaTest.java:45)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: java.lang.NullPointerException
      at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:154)
      at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:672)
      at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:654)
      at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:620)
      ... 31 more

      My persistence.xml
      <?xml version="1.0"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
      <persistence-unit name="testdb" transaction-type="RESOURCE_LOCAL">
      <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
      <class>code.TestDataBean</class>
      <class>code.shared.DataBean</class>
      <class>code.shared.AbstractDataBean</class>
      <properties>
      <!-- HSqlDb -->
      <!--
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
      <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:testdb" />
      <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" />
      <property name="openjpa.ConnectionUserName" value="sa" />
      <property name="openjpa.ConnectionPassword" value="" />
      <property name="openjpa.Log" value="DefaultLevel=TRACE" />
      -->
      <!-- MySql Cluster port 5000 -->
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
      <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
      <property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:5000/clusterdb" />
      <property name="openjpa.ConnectionUserName" value="root" />
      <property name="openjpa.ConnectionPassword" value="" />
      <property name="openjpa.BrokerFactory" value="ndb" />
      <property name="openjpa.jdbc.DBDictionary" value="TableType=ndb"/>
      <property name="openjpa.ndb.connectString" value="localhost:1186" />
      <property name="openjpa.ndb.database" value="clusterdb" />
      <property name="openjpa.Log" value="DefaultLevel=TRACE" />
      </properties>
      </persistence-unit>
      </persistence>

      1. sandbox-mysqlc6-openjpa1.zip
        8.52 MB
        Serdyn du Toit
      2. sandbox-mysqlc4.zip
        8.70 MB
        Serdyn du Toit
      3. sandbox-mysqlc16.zip
        9.16 MB
        Serdyn du Toit
      4. sandbox-mysqlc10.zip
        9.14 MB
        Serdyn du Toit
      5. sandbox-mysqlc08.zip
        9.15 MB
        Serdyn du Toit

        Activity

        Hide
        Rick Curtis added a comment -

        Since it sounds like this was a bug with the MySQL cluster implementation, I'm going to close this JIRA.

        Show
        Rick Curtis added a comment - Since it sounds like this was a bug with the MySQL cluster implementation, I'm going to close this JIRA.
        Hide
        Serdyn du Toit added a comment -

        People who want the fix NOW (without review by MySql Cluster committers) can look inside sandbox-mysqlc16.zip and just use pull the NdbOpenJPAStoreManager into their projects (classloader should use it in preference to anything found in other locations)

        Show
        Serdyn du Toit added a comment - People who want the fix NOW (without review by MySql Cluster committers) can look inside sandbox-mysqlc16.zip and just use pull the NdbOpenJPAStoreManager into their projects (classloader should use it in preference to anything found in other locations)
        Hide
        Serdyn du Toit added a comment -

        sandbox-mysqlc16.zip

        Fixed. This is however a MySql Cluster (NdbOpenJPAStoreManager OpenJpa extension not maintained in OpenJpa) issue and will be raised with them.

        Leaving this open until its resolved and anyone want to use this channel to communicate about it (close if you want)

        Show
        Serdyn du Toit added a comment - sandbox-mysqlc16.zip Fixed. This is however a MySql Cluster (NdbOpenJPAStoreManager OpenJpa extension not maintained in OpenJpa) issue and will be raised with them. Leaving this open until its resolved and anyone want to use this channel to communicate about it (close if you want)
        Hide
        Serdyn du Toit added a comment -

        sandbox-mysqlc10.zip
        Updated test to not use superclasses \ @MappedSuperclass. Same stacktrace encountered using build-time enhancement and runtime enhancement.

        The build-time enhancement error (though the entity still got enhanced) no longer appears due to no longer using superclasses.
        ([openjpac] 407 testdb ERROR [main] openjpa.Enhance - The identity field defined in the code.shared.DataBean Embeddable is not supported.)

        Notes on uploaded test:
        1. Use the Ant build file build-schema.xml for build-time enhancement.
        2. If you just import the project into Eclipse you might want to modify .classpath to reflect the location of the MySql Cluster native libraries.

        Show
        Serdyn du Toit added a comment - sandbox-mysqlc10.zip Updated test to not use superclasses \ @MappedSuperclass. Same stacktrace encountered using build-time enhancement and runtime enhancement. The build-time enhancement error (though the entity still got enhanced) no longer appears due to no longer using superclasses. ( [openjpac] 407 testdb ERROR [main] openjpa.Enhance - The identity field defined in the code.shared.DataBean Embeddable is not supported.) Notes on uploaded test: 1. Use the Ant build file build-schema.xml for build-time enhancement. 2. If you just import the project into Eclipse you might want to modify .classpath to reflect the location of the MySql Cluster native libraries.
        Hide
        Serdyn du Toit added a comment -

        Informally raised on the MySql Cluster mailing list: http://lists.mysql.com/cluster/8574

        Show
        Serdyn du Toit added a comment - Informally raised on the MySql Cluster mailing list: http://lists.mysql.com/cluster/8574
        Hide
        Serdyn du Toit added a comment -

        Updated example using OpenJpa 2.2.2.

        Use the Ant build file build-schema.xml for build-time enhancement.

        If you just import the project into Eclipse you might want to modify .classpath to reflect the location of the MySql Cluster native libraries.

        Show
        Serdyn du Toit added a comment - Updated example using OpenJpa 2.2.2. Use the Ant build file build-schema.xml for build-time enhancement. If you just import the project into Eclipse you might want to modify .classpath to reflect the location of the MySql Cluster native libraries.
        Hide
        Serdyn du Toit added a comment -

        Working OpenJpa 1 version.

        Show
        Serdyn du Toit added a comment - Working OpenJpa 1 version.
        Hide
        Serdyn du Toit added a comment -

        yep, it works with OpenJpa version 1. I'm going to revert to using OpenJpa version 1 so that I can move forward with my work. I'm not saying there's something wrong with OpenJpa version 2 - I know with complex code like this the most recent versions sometimes have small bugs (due to complexity and the pervasiveness of changes) so usually with my past experience with Hibernate I tended to use the previous version. That, and I don't need the latest JPA stuff - what I do need is the MySql Cluster extensions to work since for certain queries it bypasses communication with MySql and communicates directly with the data nodes speeding things up (MySql Cluster is like MySql but it allows sharding across data nodes and still allows you to transactions and I think scales up linearly to 30 servers - awesome, though I'm only starting to use it now). So in terms of that optimization, the communication of the data nodes, the latest OpenJpa isn't really going to make much of a difference.

        I'm changing the priority of this bug to "Minor" from "Mayor" as its no longer blocking my work.

        Show
        Serdyn du Toit added a comment - yep, it works with OpenJpa version 1. I'm going to revert to using OpenJpa version 1 so that I can move forward with my work. I'm not saying there's something wrong with OpenJpa version 2 - I know with complex code like this the most recent versions sometimes have small bugs (due to complexity and the pervasiveness of changes) so usually with my past experience with Hibernate I tended to use the previous version. That, and I don't need the latest JPA stuff - what I do need is the MySql Cluster extensions to work since for certain queries it bypasses communication with MySql and communicates directly with the data nodes speeding things up (MySql Cluster is like MySql but it allows sharding across data nodes and still allows you to transactions and I think scales up linearly to 30 servers - awesome, though I'm only starting to use it now). So in terms of that optimization, the communication of the data nodes, the latest OpenJpa isn't really going to make much of a difference. I'm changing the priority of this bug to "Minor" from "Mayor" as its no longer blocking my work.
        Hide
        Serdyn du Toit added a comment -

        From that link in my previous comment:

        "Before being able to run any ClusterJPA code, you first need to download and install OpenJPA from http://openjpa.apache.org/ – this tutorial uses OpenJPA 1.2.1. Simply extract the contents of the binary tar ball to the host you want to run your application on; for this tutorial, I use /usr/local/openjpa."

        Maybe their libraries aren't 100% compatible with OpenJpa version 2 yet. I'll test tomorrow morning first thing with OpenJpa 1 and see if I get better results.

        Show
        Serdyn du Toit added a comment - From that link in my previous comment: "Before being able to run any ClusterJPA code, you first need to download and install OpenJPA from http://openjpa.apache.org/ – this tutorial uses OpenJPA 1.2.1. Simply extract the contents of the binary tar ball to the host you want to run your application on; for this tutorial, I use /usr/local/openjpa." Maybe their libraries aren't 100% compatible with OpenJpa version 2 yet. I'll test tomorrow morning first thing with OpenJpa 1 and see if I get better results.
        Hide
        Serdyn du Toit added a comment -

        Using MySql Cluster - sorry, my bug subject just said MySql - fixed.

        > Can you confirm if the entity is or not enhance even you see the error message?
        Yes, its getting enhanced. The entity's class was 2KB before, 6KB after.

        From what class is the following?
        if (_meta.isEmbeddedOnly() && _meta.getIdentityType() == ClassMetaData.ID_APPLICATION)

        { _log.error(_loc.get("ID-field-in-embeddable-unsupported", _meta.toString())); }

        > For the second problem:
        The following two lines seem to refer to MySql Cluster custom extensions. From the documentation you sent I see the set of allowed values, but it also says that these are "plugin strings". Online example: http://www.clusterdb.com/mysql-cluster/using-clusterjpa-part-of-mysql-cluster-connector-for-java-%E2%80%93-a-tutorial/
        <property name="openjpa.BrokerFactory" value="ndb" />
        <property name="openjpa.jdbc.DBDictionary" value="TableType=ndb"/>

        I'm not (not being an OpenJpa commiter) sure how these values get translated to classes that get called at runtime.

        Do you think that it can be these custom extensions causing the problem, and not OpenJpa? If yes, then I can always raise an issue with the MySql Cluster team. Still, there doesn't seem to be anything MySql Cluster-like in the stacktrace (their classes start with com.mysql). But on the other hand - the code does work 100% with HSqlDb (and without these extensions in persistence.xml)......

        Show
        Serdyn du Toit added a comment - Using MySql Cluster - sorry, my bug subject just said MySql - fixed. > Can you confirm if the entity is or not enhance even you see the error message? Yes, its getting enhanced. The entity's class was 2KB before, 6KB after. From what class is the following? if (_meta.isEmbeddedOnly() && _meta.getIdentityType() == ClassMetaData.ID_APPLICATION) { _log.error(_loc.get("ID-field-in-embeddable-unsupported", _meta.toString())); } > For the second problem: The following two lines seem to refer to MySql Cluster custom extensions. From the documentation you sent I see the set of allowed values, but it also says that these are "plugin strings". Online example: http://www.clusterdb.com/mysql-cluster/using-clusterjpa-part-of-mysql-cluster-connector-for-java-%E2%80%93-a-tutorial/ <property name="openjpa.BrokerFactory" value="ndb" /> <property name="openjpa.jdbc.DBDictionary" value="TableType=ndb"/> I'm not (not being an OpenJpa commiter) sure how these values get translated to classes that get called at runtime. Do you think that it can be these custom extensions causing the problem, and not OpenJpa? If yes, then I can always raise an issue with the MySql Cluster team. Still, there doesn't seem to be anything MySql Cluster-like in the stacktrace (their classes start with com.mysql). But on the other hand - the code does work 100% with HSqlDb (and without these extensions in persistence.xml)......
        Hide
        Albert Lee added a comment -

        I am not any MySQL expert.

        For the first problem, it looks like the message is benign as in:

        if (_meta.isEmbeddedOnly() && _meta.getIdentityType() == ClassMetaData.ID_APPLICATION)

        { _log.error(_loc.get("ID-field-in-embeddable-unsupported", _meta.toString())); }

        Can you confirm if the entity is or not enhance even you see the error message? You can check the size of the entity class file before and after the enhancement. The message is a little bit confusing.

        For the second problem:

        From looking at the p.xml, the BrokerFactory is set to "ndb". Based on http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#openjpa.BrokerFactory,

        Possible values: jdbc, abstractstore, remote

        Also the DBDictionary's table type is set to "ndb", a quick look at http://www.mysqltutorial.org/understand-mysql-table-types-innodb-myisam.aspx does not show ndb is any supported type.

        Is the "ndb" brokerFactory your custom implementation of the BrokerFactory?

        Show
        Albert Lee added a comment - I am not any MySQL expert. For the first problem, it looks like the message is benign as in: if (_meta.isEmbeddedOnly() && _meta.getIdentityType() == ClassMetaData.ID_APPLICATION) { _log.error(_loc.get("ID-field-in-embeddable-unsupported", _meta.toString())); } Can you confirm if the entity is or not enhance even you see the error message? You can check the size of the entity class file before and after the enhancement. The message is a little bit confusing. For the second problem: From looking at the p.xml, the BrokerFactory is set to "ndb". Based on http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#openjpa.BrokerFactory , Possible values: jdbc, abstractstore, remote Also the DBDictionary's table type is set to "ndb", a quick look at http://www.mysqltutorial.org/understand-mysql-table-types-innodb-myisam.aspx does not show ndb is any supported type. Is the "ndb" brokerFactory your custom implementation of the BrokerFactory?
        Hide
        Serdyn du Toit added a comment -

        Test case to illustrate. Use the Ant file build-schema.xml for build-time enhancement. Everything works in HSqlDb, but if you modify the persistence.xml for MySql Cluster it fails.

        Show
        Serdyn du Toit added a comment - Test case to illustrate. Use the Ant file build-schema.xml for build-time enhancement. Everything works in HSqlDb, but if you modify the persistence.xml for MySql Cluster it fails.

          People

          • Assignee:
            Unassigned
            Reporter:
            Serdyn du Toit
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development