Bug #50925 OpenJPA/ClusterJ Table dictionary lookups fails for non 'test' named DBs.
Submitted: 4 Feb 2010 18:04 Modified: 12 Mar 2010 14:04
Reporter: Alexander Yu Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Cluster: Cluster/J Severity:S3 (Non-critical)
Version:7.1.1 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: Cluster/J, MySQL Cluster, openjpa

[4 Feb 2010 18:04] Alexander Yu
Description:
Playing with openjpa/clusterj and glassfish. 

Got table dictionary lookups that failed for non 'test' named DBs. By moving the tables to 'test' I didn't get those exceptions.

NdbOpenJPAConfigurationImpl(boolean derivations, boolean loadGlobals) {..} has the database hardcoded to 'test' even after setting a correct db name.

Stacktrace below
-- 
WARNING: JSF1063: WARNING! Setting non-serializable attribute value into HttpSession (key: cityController, value class: ndb.jsf.world.CityController).
    loading the NDB JTie library ...
    initializing the JTie resources ...
    ... initialized the JTie resources
    initializing the NDBAPI resources ...
    ... initialized the NDBAPI resources
    initializing the MySQL Utilities resources ...
    ... initialized the MySQL Utilities resources
INFO: CITY RANGE:0, 10
SEVERE: 6684  OpenJPAWorldPU  INFO   [http-thread-pool-8080-(2)] openjpa.Runtime - Starting OpenJPA 1.2.2

SEVERE: 6758  OpenJPAWorldPU  INFO   [http-thread-pool-8080-(2)] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".

INFO: Updating configuration from org.apache.felix.fileinstall-autodeploy-bundles.cfg
INFO: Installed /Applications/NetBeans/sges-v3/glassfish/modules/autostart/org.apache.felix.fileinstall-autodeploy-bundles.cfg
INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = /Applications/NetBeans/sges-v3/glassfish/domains/domain1/autodeploy/bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = /var/folders/PD/PD3XITUIG481TJpPYfAoOU+++TI/-Tmp-/fileinstall-1782565553258392100, felix.fileinstall.filter = null}
INFO: Found 0 DomainTypeHandlerFactories
INFO: loading libary...
INFO: ... [ndbjtie]
SEVERE: Error in NdbJTie: returnCode , code 723, mysqlCode 155, status 2, classification 4, message No such table existed CITY.
SEVERE: com.mysql.clusterj.ClusterJDatastoreException: Error in NdbJTie: returnCode , code 723, mysqlCode 155, status 2, classification 4, message No such table existed CITY.
        at com.mysql.clusterj.tie.Utility.throwError(Utility.java:552)
        at com.mysql.clusterj.tie.DictionaryImpl.handleError(DictionaryImpl.java:81)
        at com.mysql.clusterj.tie.DictionaryImpl.getTable(DictionaryImpl.java:57)
        at com.mysql.clusterj.openjpa.NdbOpenJPADomainTypeHandlerImpl.<init>(NdbOpenJPADomainTypeHandlerImpl.java:104)
        at com.mysql.clusterj.openjpa.NdbOpenJPAConfigurationImpl.createDomainTypeHandler(NdbOpenJPAConfigurationImpl.java:280)
        at com.mysql.clusterj.openjpa.NdbOpenJPAConfigurationImpl.getDomainTypeHandler(NdbOpenJPAConfigurationImpl.java:266)
        at com.mysql.clusterj.openjpa.NdbOpenJPAStoreManager.getDomainTypeHandler(NdbOpenJPAStoreManager.java:104)
        at com.mysql.clusterj.openjpa.NdbOpenJPAStoreManager.getDomainTypeHandler(NdbOpenJPAStoreManager.java:100)
        at com.mysql.clusterj.openjpa.NdbOpenJPAStoreManager.initialize(NdbOpenJPAStoreManager.java:196)
        at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
        at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
        at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:913)
        at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:871)
        at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:793)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:986)
        at com.mysql.clusterj.openjpa.NdbOpenJPAStoreManager.load(NdbOpenJPAStoreManager.java:167)
        at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:278)
        at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2413)
        at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:272)
        at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
        at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
        at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:848)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:779)
        at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
        at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
        at ndb.jpa.world.CityFacade.findRange(CityFacade.java:55)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

How to repeat:
Setup openjpa/clusterj with glassfish. Create and use an JPA entity class. 
Use a DB name other than 'test' and you should get the below error.

--
SEVERE: Error in NdbJTie: returnCode , code 723, mysqlCode 155, status 2, classification 4, message No such table existed CITY.
SEVERE: com.mysql.clusterj.ClusterJDatastoreException: Error in NdbJTie: returnCode , code 723, mysqlCode 155, status 2, classification 4, message No such table existed CITY.
        at com.mysql.clusterj.tie.Utility.throwError(Utility.java:552)
        at com.mysql.clusterj.tie.DictionaryImpl.handleError(DictionaryImpl.java:81

Suggested fix:
com.mysql.clusterj.openjpa.NdbOpenJPAConfigurationImpl(boolean derivations, boolean loadGlobals) {..} has the database hardcoded to 'test' even after setting a correct db name.
[5 Feb 2010 14:00] Bernd Ocklin
Hi Alex,

have you tried to set 

      <property name="openjpa.ndb.database" value="tt"/>

in your persistence.xml? There are some difficulties with glassfish picking up changes if JNDI is not restarted properly after deployment.
[9 Feb 2010 15:06] Alexander Yu
Hi Bernd,
I'm getting inconsistent results. The no such table error pops up now and then. But it does not seem to be related to the test database name anymore.

My persistence.xml below for your reference.

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    <persistence-unit name="OpenJPAWorldPU" transaction-type="JTA">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <jta-data-source>mysqlworld</jta-data-source>
    <class>ndb.jpa.world.City</class>
    <class>ndb.jpa.world.Country</class>
    <class>ndb.jpa.world.Countrylanguage</class>
    <properties>
        <property name="openjpa.ndb.database" value="world"/>
        <property name="openjpa.BrokerFactory" value="com.mysql.clusterj.openjpa.NdbOpenJPABrokerFactory"/>
        <property name="openjpa.ndb.connectString" value="localhost:1186"/>
        <property name="openjpa.ndb.connectVerbose" value="1"/>
        <property name="openjpa.ConnectionRetainMode" value="transaction"/>
        <property name="openjpa.DataCache" value="false"/>
    </properties>
  </persistence-unit>
</persistence>
[12 Feb 2010 14:03] Craig Russell
Have you set the "use lower case" flag in the MySQL Server? 

This sounds like a case issue. ClusterJ will take the name you specify and use it directly and then if not found, will lower-case the name. 

http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
[13 Mar 2010 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[16 Mar 2010 21:03] Craig Russell
I've added a test in the clusterj suite to make sure that databases other than test can be used.

I still need a test for the clusterjpa path...

clr% bzr commit -m "Add test for database property in connection properties" clusterj-test clusterj-tie/src/test/java/testsuite/clusterj/tie/FindByPrimaryKey2Test.java
Committing to: /Users/clr/ndb/root/clusterj-working/                                                                                                                                                                                
added clusterj-test/src/main/java/testsuite/clusterj/FindByPrimaryKey2Test.java
added clusterj-test/src/main/java/testsuite/clusterj/model/Employee2.java
modified clusterj-test/src/main/resources/schema.sql
added clusterj-tie/src/test/java/testsuite/clusterj/tie/FindByPrimaryKey2Test.java
Committed revision 228.                                                                                                                                                                                                             
[CraigRussell:~/ndb/root/clusterj-working] clr% bzr push 
Using saved push location: bzr+ssh://crussell@bk-internal.mysql.com/bzrroot/clusterj/
Pushed up to revision 228.                                                                                                                                                                                                          
[CraigRussell:~/ndb/root/clusterj-working] clr% pushd ../clusterj ; bzr pull ; popd~/ndb/root/clusterj ~/ndb/root/clusterj-working 
Using saved parent location: bzr+ssh://crussell@bk-internal.mysql.com/bzrroot/clusterj/
+N  clusterj-test/src/main/java/testsuite/clusterj/FindByPrimaryKey2Test.java                                                                                                                                                       
+N  clusterj-test/src/main/java/testsuite/clusterj/model/Employee2.java
+N  clusterj-tie/src/test/java/testsuite/clusterj/tie/FindByPrimaryKey2Test.java
 M  clusterj-test/src/main/resources/schema.sql
All changes applied successfully.
Now on revision 228.
~/ndb/root/clusterj-working