Quantcast
Channel: MySQL Forums - NDB clusters
Viewing all articles
Browse latest Browse all 1562

JpaCluster on Glassfish using persistence.xml: Can not connect to 192.168.56.101 (1 reply)

$
0
0
Doing some prototyping with openJPA + JpaCluster + Sailfin 2 (based on glassfish 2.1) +
JPA.

Using the following persistence.xml:
<persistence-unit name="BM" transaction-type="JTA">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<jta-data-source>jdbc/bm</jta-data-source>
<class>persist.BigCompany</class>
<class>persist.SmallEmployee</class>
<properties>
<property name="openjpa.BrokerFactory" value="ndb"/>
<property name="openjpa.ndb.connectString" value="192.168.56.101:1186"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(SchemaAction='add')"/>
<property name="openjpa.ConnectionRetainMode" value="transaction"/>
<property name="openjpa.ndb.database" value="bm"/>
<property name="openjpa.ndb.connectVerbose" value="1"/>
<property name="openjpa.DataCache" value="false"/>
<property name="openjpa.ConnectionUserName" value="root"/>
<property name="openjpa.ConnectionPassword" value="system"/>
</properties>
</persistence-unit>

Cluster-j seems to fail to connect to a data node:

Caused by: <openjpa-1.2.2-r422266:898935 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: Error getting connection to cluster
with properties {com.mysql.clusterj.connect.verbose=1,
com.mysql.clusterj.connect.retries=4, com.mysql.clusterj.connect.delay=5,
com.mysql.clusterj.connectstring=192.168.56.101:1186,
com.mysql.clusterj.max.transactions=1024, com.mysql.clusterj.connect.timeout.before=30,
com.mysql.clusterj.database=bm, com.mysql.clusterj.connect.timeout.after=20} Caused by
com.mysql.clusterj.ClusterJDatastoreException:Datastore exception Return code: -1 error
code: 0 message: .
at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:196)
at
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at
com.sun.enterprise.util.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:326)
at com.sun.enterprise.util.EntityManagerWrapper.persist(EntityManagerWrapper.java:440)
at loader.MyLoader.createCompany(MyLoader.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2929)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4020)
at
com.sun.ejb.containers.WebServiceInvocationHandler.invoke(WebServiceInvocationHandler.java:190)
... 63 more
Caused by: com.mysql.clusterj.ClusterJFatalException: Error getting connection to cluster
with properties {com.mysql.clusterj.connect.verbose=1,
com.mysql.clusterj.connect.retries=4, com.mysql.clusterj.connect.delay=5,
com.mysql.clusterj.connectstring=192.168.56.101:1186,
com.mysql.clusterj.max.transactions=1024, com.mysql.clusterj.connect.timeout.before=30,
com.mysql.clusterj.database=bm, com.mysql.clusterj.connect.timeout.after=20} Caused by
com.mysql.clusterj.ClusterJDatastoreException:Datastore exception Return code: -1 error
code: 0 message: .
at com.mysql.clusterj.core.SessionFactoryImpl.<init>(SessionFactoryImpl.java:145)
at
com.mysql.clusterj.core.SessionFactoryImpl.getSessionFactory(SessionFactoryImpl.java:108)
at
com.mysql.clusterj.core.SessionFactoryServiceImpl.getSessionFactory(SessionFactoryServiceImpl.java:36)
at
com.mysql.clusterj.core.SessionFactoryServiceImpl.getSessionFactory(SessionFactoryServiceImpl.java:27)
at com.mysql.clusterj.ClusterJHelper.getSessionFactory(ClusterJHelper.java:61)
at com.mysql.clusterj.ClusterJHelper.getSessionFactory(ClusterJHelper.java:46)
at
com.mysql.clusterj.openjpa.NdbOpenJPAConfigurationImpl.createSessionFactory(NdbOpenJPAConfigurationImpl.java:261)
at
com.mysql.clusterj.openjpa.NdbOpenJPAConfigurationImpl.getSessionFactory(NdbOpenJPAConfigurationImpl.java:228)
at
com.mysql.clusterj.openjpa.NdbOpenJPAConfigurationImpl.getSessionFactory(NdbOpenJPAConfigurationImpl.java:52)
at
com.mysql.clusterj.openjpa.NdbOpenJPAStoreManager.setContext(NdbOpenJPAStoreManager.java:99)
at
com.mysql.clusterj.openjpa.NdbOpenJPAStoreManager.setContext(NdbOpenJPAStoreManager.java:93)
at
org.apache.openjpa.kernel.DelegatingStoreManager.setContext(DelegatingStoreManager.java:78)
at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:311)
at
org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:216)
at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:190)
... 78 more
Caused by: com.mysql.clusterj.ClusterJDatastoreException: Datastore exception Return
code: -1 error code: 0 message: .
at
com.mysql.clusterj.tie.ClusterConnectionImpl.throwError(ClusterConnectionImpl.java:143)
at
com.mysql.clusterj.tie.ClusterConnectionImpl.handleError(ClusterConnectionImpl.java:120)
at
com.mysql.clusterj.tie.ClusterConnectionImpl.waitUntilReady(ClusterConnectionImpl.java:113)
at com.mysql.clusterj.core.SessionFactoryImpl.<init>(SessionFactoryImpl.java:143)
... 92 more
|#]

in the ndb_mgm show I can see available mysqld(API) nodes:
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @127.0.0.1 (mysql-5.1.47 ndb-7.1.8, Nodegroup: 0, Master)
id=4 @127.0.0.1 (mysql-5.1.47 ndb-7.1.8, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @127.0.0.1 (mysql-5.1.47 ndb-7.1.8)

[mysqld(API)] 4 node(s)
id=50 @127.0.0.1 (mysql-5.1.47 ndb-7.1.8)
id=51 (not connected, accepting connect from any host)
id=52 (not connected, accepting connect from any host)
id=53 (not connected, accepting connect from any host)

I am using the default config.ini:

[ndb_mgmd]
hostname=localhost
datadir=/home/baboune/ndb/one-cluster/ndb_data
id=1

[ndbd default]
noofreplicas=2
datadir=/home/baboune/ndb/one-cluster/ndb_data

[ndbd]
hostname=localhost
id=3

[ndbd]
hostname=localhost
id=4

[mysqld]
id=50

[mysqld]
id=51

[mysqld]
id=52

[mysqld]
id=53

And my.cnf:

[mysqld]
ndbcluster
datadir=/home/baboune/ndb/one-cluster/mysqld_data
basedir=/home/baboune/mysqlc

Note: if I remove the ndb parts in the persistence.xml then everything works as my data
source points to a valid MySQL connection pool.

How to repeat:
Using above persistence.xml configuration deploy an application on a glassfish server.

Some comments on my setup:
- Main machine using windows 7 64 bits running Glassfish
- Virtual machine running Ubuntu Maverick 32 bits + Mysql cluster

Tried the exact same thing but with everything collocated on windows and I seem to get a
link towards the DB:

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Can't create table
'bm.bigcompany' (errno: 157) {stmnt 202688481 CREATE TABLE BIGCOMPANY (id BIGINT NOT NULL
AUTO_INCREMENT, name VARCHAR(255), PRIMARY KEY (id)) TYPE = ndbcluster} [code=1005,
state=HY000]
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:762)
at
org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:114)
at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1191)
at org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:949)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:526)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:344)
at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:321)
at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:501)
... 82 more

It is still not good but at least it appears to connect to the NDB API.

So there is some sort of bug going to an external NDB API (not localhost)?

Viewing all articles
Browse latest Browse all 1562

Trending Articles