persistance.xml file :
<?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">
<persistence-unit name="RAT_MongoDB_Try1" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.ogm.datastore.provider" value="MONGODB"/>
<property name="hibernate.ogm.datastore.database" value="***" />
<property name="hibernate.ogm.datastore.host" value="27017" />
<property name="hibernate.ogm.datastore.create_database" value="true" />
<property name="hibernate.ogm.datastore.username" value="***" />
<property name="hibernate.ogm.datastore.password" value="***" />
</properties>
</persistence-unit>
</persistence>
Dependencies in pom.xml :
<dependencies>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-bom</artifactId>
<version>5.4.1.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
<version>1.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.narayana.jta</groupId>
<artifactId>narayana-jta</artifactId>
<version>5.11.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-transaction-spi</artifactId>
<version>7.6.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-infinispan-embedded</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jbossjta</artifactId>
<version>4.2.2.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.jbossts</groupId>
<artifactId>jbossjta</artifactId>
<version>4.16.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.jbossts.arjunacore</groupId>
<artifactId>arjuna</artifactId>
<version>4.17.4.Final</version>
</dependency>
</dependencies>
My java file modified from the github example:
TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "ogm-jpa-tutorial" );
try {
tm.begin();
EntityManager em = emf.createEntityManager();
User user = new User();
user.setName( "User" );
em.persist( user );
String userId = user.getId();
em.flush();
em.close();
tm.commit();
tm.begin();
em = emf.createEntityManager();
user = em.find( User.class, userId );
System.out.println("Found User :"+ user.getName());
em.flush();
em.close();
tm.commit();
emf.close();
Entity User :
@Entity
public class User {
private String id;
private String name;
@Id @GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name;}
}
The code above is just the modified code for the Github Example Repo and it still doesn’t work.
The error states :
Caused by: java.lang.ClassNotFoundException: com.arjuna.common.util.propertyservice.PropertyManagerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
I have tried with two or three dependencies for the PropertyManagerFactory
already. What am I supposed to do now?
Please help.