我使用Kundera和Datastax DS Driver进行Cassandra连接。 在persistence.xml上,我将端口定义为9042。
然而,我注意到昆德拉未能连接到卡桑德拉:
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.503 sec <<< FAILURE! - in com.abc.DataServiceImplTest
writeReadTest(com.abc.DataServiceImplTest) Time elapsed: 0.38 sec <<< ERROR!
com.impetus.kundera.configure.schema.SchemaGenerationException: Error while opening socket, Caused by: .
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.initiateClient(CassandraSchemaManager.java:718)
at com.impetus.kundera.configure.schema.api.AbstractSchemaManager.exportSchema(AbstractSchemaManager.java:112)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.exportSchema(CassandraSchemaManager.java:166)
at com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConfiguration.java:191)
at com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactoryMetadata(ClientMetadataBuilder.java:48)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClientFactories(EntityManagerFactoryImpl.java:408)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(EntityManagerFactoryImpl.java:161)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:135)
at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(KunderaPersistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
一旦我在/etc/cassandra/cassandra.yaml启用了Thrift端口(9160),事情就开始了。
这是persistence.xml:
<persistence-unit name="cassandra_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>com.abc.Person</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9042" />
<property name="kundera.keyspace" value="testkeyspace" />
<property name="kundera.ddl.auto.prepare" value="update" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.client.lookup.class"
value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />
<property name="kundera.annotations.scan.package" value="com.abc.impl"/>
</properties>
想知道即使使用DS-Driver也需要启用9160?
谢谢!
答案 0 :(得分:0)
kundera.ddl.auto.prepare
通过thrift方式工作,该方式适用于端口9160,但您正在使用datastax&amp;提供的com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory
。适用于您在persistence.xml
中提到的端口9042。所以,
删除此行
<property name="kundera.ddl.auto.prepare" value="update" />
persistence.xml
的将解决此问题。