Description:
I have previous developed a Java app with ClusterJPA as the persistence framework on a linux machine. After installing MySQL Cluster 7.2.8 in Windows and moving the app to a Windows environment, my app could not run due to the following exception:
SEVERE: Attempt to load native library ndbclient from path c:\mysql\lib failed with class java.lang.UnsatisfiedLinkError (no ndbclient in java.library.path).
Exception in thread "main" <openjpa-2.2.0-r422266:1244990 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Error getting connection to cluster with properties {com.mysql.clusterj.connect.verbose=0, com.mysql.clusterj.connect.retries=4, com.mysql.clusterj.connect.delay=5, com.mysql.clusterj.connectstring=localhost:1186, com.mysql.clusterj.max.transactions=1024, com.mysql.clusterj.connect.timeout.before=30, com.mysql.clusterj.database=housedb, com.mysql.clusterj.connect.timeout.after=20}:
Caused by com.mysql.clusterj.ClusterJFatalUserException:Attempt to load native library ndbclient from path c:\mysql\lib failed with class java.lang.UnsatisfiedLinkError (no ndbclient in java.library.path). Caused by java.lang.UnsatisfiedLinkError:no ndbclient in java.library.path
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:218)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
at aa.Main.main(Main.java:20)
It seems to me that the ndbclient is missing from the lib folder. In fact in Windows' version of the lib folder, only "ndbclient_static.lib" is present. On the other hand, in linux, various files (libndbclient.so, libndbclient.so.6.0.0, libndbclient_static.a & ndb_engine.so) are present.
How to repeat:
1. Create a database
2. Create a Java application, include lib that are required by ClusterJPA (including clusterjpa, clusterj, connector/j, openjpa, asm.jar)
3. Setup the persistance.xml file in a META-INF folder, including at the following settings (referenced from http://dev.mysql.com/doc/ndbapi/en/mccj-using-jpa.html)
<persistence-unit name="personnel" transaction-type="RESOURCE_LOCAL">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<class>test.Employee</class>
<properties>
<property name="openjpa.BrokerFactory" value="ndb"/>
<property name="openjpa.ndb.connectString" value="localhost:1186"/>
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/test"/>
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="openjpa.ConnectionRetainMode" value="transaction"/>
</properties>
</persistence-unit>
4. Run the app/class with the following settings -Djava.library.path=c:/mysql/lib/ , where c:/mysql/lib/ is the path to the lib folder in the MySQL Cluster folder. Also add classpath to the other .jar files that are required (including clusterjpa, clusterj, connector/j, openjpa, asm.jar).
Suggested fix:
Add the windows version of the ndbclient into the lib folder, similar to the linux version.