Skip to content

Instantly share code, notes, and snippets.

@Alex-Ikanow
Last active December 16, 2015 13:59
Show Gist options
  • Save Alex-Ikanow/5445445 to your computer and use it in GitHub Desktop.
Save Alex-Ikanow/5445445 to your computer and use it in GitHub Desktop.
Kundera / MongoDB issues (Kundera 2.2.1)
/////////////////////////////////////////////
//
// 1] persistence.xml (in classpath - when I move it a get a different set of errors)
<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_1_0.xsd" version="2.0">
<persistence-unit name="mongoPU">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.client.lookup.class" value="com.impetus.client.mongodb.MongoDBClientFactory"/>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="27017" />
<property name="kundera.keyspace" value="KunderaTest" />
<property name="kundera.dialect" value="mongodb" />
<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>
/////////////////////////////////////////////
//
// 2] KunderaControlTest.java
package com.ikanow.infinit.e.harvest.test;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "TEST_CLASS", schema = "KunderaTest@mongoPU")
public class KunderaControlTest {
@Id
private String idField;
@Column(name="TEST_FIELD")
private String testField;
// Functions, no annotations needed
public KunderaControlTest() {}
public void setTestField(String testField) {
this.testField = testField;
}
public String getTestField() {
return testField;
}
public void setIdField(String idField) {
this.idField = idField;
}
public String getIdField() {
return idField;
}
}
/////////////////////////////////////////////
//
// 3] NoSqlHarvestTest.java
package com.ikanow.infinit.e.harvest.test;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class NoSqlHarvestTest {
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
KunderaControlTest controlInstance = new KunderaControlTest();
controlInstance.setIdField("control_id");
controlInstance.setTestField("control_instance");
EntityManagerFactory factory = Persistence.createEntityManagerFactory("mongoPU");
EntityManager manager = factory.createEntityManager();
System.out.println("Persisting control instance...");
manager.persist(controlInstance);
manager.close();
factory.close();
}
}
/////////////////////////////////////////////
//
// 4] Errors
13/04/23 13:01:26 INFO kundera.KunderaPersistence: Loading Core
13/04/23 13:01:26 INFO loader.CoreLoader: Loading Kundera Core Metdata ...
13/04/23 13:01:26 INFO kundera.KunderaPersistence: Loading Application MetaData and Initializing Client(s) For Persistence Unit(s) mongoPU
13/04/23 13:01:26 INFO configure.PersistenceUnitConfiguration: Loading Metadata from persistence.xml ...
13/04/23 13:01:26 INFO configure.PersistenceUnitConfiguration: Finishing persistence unit metadata configuration ...
13/04/23 13:01:26 INFO configure.ClientFactoryConfiguraton: Loading Client(s) For Persistence Unit(s) mongoPU
13/04/23 13:01:26 INFO client.ClientResolver: Initializing client factory for: mongoPU
13/04/23 13:01:26 INFO client.ClientResolver: Finishing factory initialization
13/04/23 13:01:26 INFO loader.GenericClientFactory: Loading client metadata for persistence unit : mongoPU
13/04/23 13:01:26 INFO loader.GenericClientFactory: Initializing client for persistence unit : mongoPU
13/04/23 13:01:26 WARN config.MongoDBPropertyReader: No property file found in class path, kundera will use default property
13/04/23 13:01:26 INFO loader.GenericClientFactory: Constructing pool for persistence unit : mongoPU
13/04/23 13:01:26 INFO mongodb.MongoDBClientFactory: Connecting to mongodb at localhost on port 27017
13/04/23 13:01:27 INFO mongodb.MongoDBClientFactory: Connected to mongodb at localhost on port 27017
13/04/23 13:01:27 INFO mongodb.MongoDBClientFactory: Connected to mongodb at localhost on port 27017
13/04/23 13:01:27 INFO configure.MetamodelConfiguration: No class to scan for persistence unit mongoPU. Entities will be loaded from classpath/ context-path
13/04/23 13:01:27 INFO configure.SchemaConfiguration: Configuring schema export for: mongoPU
13/04/23 13:01:27 INFO persistence.EntityManagerFactoryImpl: EntityManagerFactory created for persistence unit : mongoPU
13/04/23 13:01:27 INFO client.ClientResolver: Returning client instance for:mongoPU
Persisting control instance...
13/04/23 13:01:27 WARN metadata.KunderaMetadataManager: No Entity metadata found for the class class com.ikanow.infinit.e.harvest.test.KunderaControlTest. Any CRUD operation on this entity will fail.If your entity is for RDBMS, make sure you put fully qualified entity class name under <class></class> tag in persistence.xml for RDBMS persistence unit. Returning null value.
13/04/23 13:01:27 ERROR persistence.PersistenceValidator: class com.ikanow.infinit.e.harvest.test.KunderaControlTest is not a JPA managed object as we couldn't find metadata for it. This object can't be persisted
Exception in thread "main" com.impetus.kundera.KunderaException: java.lang.IllegalArgumentException: Entity object is invalid, operation failed. Please check previous log message for details
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:208)
at com.ikanow.infinit.e.harvest.test.NoSqlHarvestTest.main(NoSqlHarvestTest.java:132)
Caused by: java.lang.IllegalArgumentException: Entity object is invalid, operation failed. Please check previous log message for details
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:143)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:202)
... 1 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment