0

I'm new in cassandra, trying to integrate cassandra using Kundera 3.5 with my java app on play framework(v2.3). I have gone through this documentation. but I'm getting this error.

    [CompletionException: com.impetus.kundera.loader.MetamodelLoaderException: Error while retreiving and storing entity metadata]

I created the necessary schema and column family in my DB. Also having the jar for my Entity. Can alyone tell me whats the thnig that I missed

my persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
<persistence-unit name="cassandra_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<jar-file>entities.jar</jar-file>
<class>models.User</class>
<properties>
    <property name="kundera.nodes" value="127.0.0.1"/>
    <property name="kundera.port" value="9042"/>
    <property name="kundera.keyspace" value="KunderaExamples"/>
    <property name="kundera.dialect" value="cassandra"/>
    <property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
    <property name="kundera.cache.provider.class" value="com.impetus.kundera.cache.ehcache.EhCacheProvider"/>
    <property name="kundera.cache.config.resource" value="/ehcache-test.xml"/>
</properties>
</persistence-unit>
</persistence>

my model class User.java

package models;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "users", schema = "KunderaExamples@cassandra_pu")
public class User
{
    @Id
    private String userId;

    @Column(name="first_name")
    private String firstName;

    @Column(name="last_name")
    private String lastName;

    @Column(name="city")
    private String city;

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getUserId() {
        return userId;
    }

    public String getCity() {
        return city;
    }

    public String getLastName() {
        return lastName;
    }

    public String getFirstName() {
        return firstName;
    }

}

1 Answers1

0

The error can be due to twice declaration of User entity in <class> tag and <jar-file> tag.

Try this persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
<persistence-unit name="cassandra_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>models.User</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
    <property name="kundera.nodes" value="127.0.0.1"/>
    <property name="kundera.port" value="9042"/>
    <property name="kundera.keyspace" value="KunderaExamples"/>
    <property name="kundera.dialect" value="cassandra"/>
    <property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
</properties>
</persistence-unit>
</persistence>
Dev
  • 13,492
  • 19
  • 81
  • 174