Getting java.lang.NoSuchFieldError: ERRORS_IGNORED for hibernate-ogm with mongodb

598 views Asked by At

I am trying to use hibernate-ogm with mongodb and getting no such fieds error

persistence.xml

<persistence-unit name="mongodb-test" transaction-type="JTA">        
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.ogm.datastore.provider" value="mongodb"></property>
<property name="hibernate.ogm.datastore.host" value="192.168.0.237"></property>
<property name="hibernate.ogm.datastore.create_database" value="true"></property>
<property name="hibernate.ogm.datastore.database" value="anand_test"></property>
<property name="hibernate.ogm.mongodb.connection_timeout" value="5000"></property>
<property name="hibernate.ogm.mongodb.authentication_mechanism" value="PLAIN"></property>
<property name="hibernate.ogm.datastore.document.association_storage" value="IN_ENTITY"></property>
<property name="hibernate.ogm.mongodb.association_document_storage" value="GLOBAL_COLLECTION"></property>
<property name="hibernate.ogm.mongodb.write_concern" value="ACKNOWLEDGED"></property>
<property name="hibernate.ogm.mongodb.read_preference" value="PRIMARY_PREFERRED"></property>
</properties>
</persistence-unit>

Person.java

import javax.persistence.Entity;
import javax.persistence.Id;
import org.bson.types.ObjectId;
import org.hibernate.annotations.Type;

@Entity
public class Person {            
@Id
@Type(type = "objectid")
private String id;         
private String firstName;
private String lastName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}   
public Person(){        
}

public Person(String firstName,String lastName){
this.firstName = firstName;
this.lastName = lastName;
}
}

TestMongoconnection.java

import com.mongodb.Person;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class TestMongoConnection {
public static void main(String[] args) {
EntityManagerFactory entityManagerFactory =          Persistence.createEntityManagerFactory("mongodb-test");
EntityManager manager = entityManagerFactory.createEntityManager();
manager.getTransaction().begin();
Person anandMohan = new Person("Anand","Mohan");
manager.persist(anandMohan);
manager.getTransaction().commit();        
manager.close();
}
}

I am having mongodb version 3.0.2 and hibernate-ogm 4.2.0 final with mongodb java version 3.x jars

1

There are 1 answers

0
Anand Mohan On BEST ANSWER

The problem is with the java jar version of the mongodb as 3.x version is not yet supported have to use 2.x version of it

https://forum.hibernate.org/viewtopic.php?f=31&t=1040127&p=2485319#p2485319