2

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 ...

superstarz
  • 89
  • 1
  • 11
  • It looks like some property is not mapped at all -- hence the NPE when it tries to tell you which class it is. Have you tried asking the Kundera folks about it? – Christopher Schultz Jun 19 '12 at 00:21
  • mmh what is Kundera folks please ? I was typing it on google but no concrete result. My persistence.xml is find by my project, but I think the problem is the hierarchy of my . – superstarz Jun 19 '12 at 09:07

2 Answers2

1

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).

Ravindranath Akila
  • 209
  • 3
  • 35
  • 45
0

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

vivek mishra
  • 1,162
  • 8
  • 16
  • WellBack Vivek My persistence.xml is already in this folder with this line : net.***.common.db.***.FileCassandra When I delete this file, i got an another error, in this case, my project find my persistence file. The problem is the definition of entity class. This exception is throw when I try to persist data in my database. The declaration of my ententy Manager and my entity manager factory work fine. EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu"); EntityManager em = emf.createEntityManager(); – superstarz Jun 19 '12 at 12:49
  • Could you please share the error you getting. is it different than "No EntityMetadata found" ? Can you connect with me on my yahoo ID? – vivek mishra Jun 19 '12 at 14:17
  • I can create an account for yahoo, but I have an idea about to resolve this problem. When I Decompile KunderaMetadataManager I found exception is throw But its strange because my error messsage is this : com.impetus.kundera.metadata.KunderaMetadataManager - No Entity metadata found for the class class net.esi.common.db.ged.FileCassandra. Any CRUD operation on this entity will fail.If your entity is for RDBMS, make sure you put fully qualified entity class name under tag in persistence.xml for RDBMS persistence unit. Returning null value. The "class" word is said 2 times ... – superstarz Jun 19 '12 at 14:31
  • You are right about that thing. But as you are telling it is working via Junit, it means configuration is fine and only thing is it is not able to load your classes from classpath – vivek mishra Jun 19 '12 at 14:39
  • But vivek, this message use "entityClass", but this var is the same then which I write in in Persistence.xml. maybe the problem is the entiTyClass is like that : "class net.esi.common.db.ged.FileCassandra" instead of just "net.esi.common.db.ged.FileCassandra" " – superstarz Jun 19 '12 at 14:44
  • That's fine. Can you verify your webapp structure as per: https://github.com/impetus-opensource/Kundera-Examples/issues/10 (See last 2 comments) – vivek mishra Jun 19 '12 at 14:49
  • My problem was resolved with Vivek, my Jar File was not loaded the result was my EntityClass coundnt not be loaded. I just put my GED.jar into the library of tomcat, and thats work – superstarz Jun 20 '12 at 12:24