superstarz
superstarz

Reputation: 89

No Entity metadata found for the class

I'm back with the same problem ...

I'm trying to uses queries in my Cassandra DB with Kundera (Cassandra ORM), this queries work in an others project but when I try to do it in webapp (using tomcat 6.0), I got this error :

com.impetus.kundera.metadata.KunderaMetadataManager  - No Entity metadata found for the class

=> JavaNullPointerException.

But when I leave the persistence.xml from my project I got an other error. (NoPersistence.xml found or something ... )

So, my project found Persistence.xml, but not my Entity class : fileCassandra.

You can see my persistence.xml :

   <?xml version="1.0" encoding="UTF-8"?>
<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">
    <!--  192.168.3.107 -->
    <persistence-unit name="cassandra_pu">
        <provider>com.impetus.kundera.KunderaPersistence</provider>     
        <class>net.***.common.db.***.FileCassandra</class>

        <properties>            
            <property name="kundera.nodes" value="localhost"/>
            <property name="kundera.port" value="9160"/>
            <property name="kundera.keyspace" value="KunderaExamples"/>
            <property name="kundera.dialect" value="cassandra"/>
            <property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />
            <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>  

net..common.db..FileCassandra I must replace by * because it's name from my companie ;)

The same methods (include EntityManager) works in junit on other project, when I build my project in Tomcat, this error appears ...

Upvotes: 2

Views: 1834

Answers (2)

Ravindranath Akila
Ravindranath Akila

Reputation: 47

This happens when you have multiple entries of the same class in your classpath.

The ideal place to have your entities is closest to the same class loader which loads kundera core and client(HBase, Cassandra etc.).

For example, if these kundera files are under WEB-INF/lib, you'd rather have your entities under the application where as if kundera files are on the applications lib folder, better bundle your entities in a jar and put them there (and remove the entities in your app).

Upvotes: 1

vivek mishra
vivek mishra

Reputation: 1162

Only issue which i can see is classes and persistence.xml location.

try to place persistence.xml within /WEB-INF/classes/META-INF/, Provided that your entity definitions are within classes folder!

-Vivek

Upvotes: 0

Related Questions