Hi experts
I want to insert some Data in a Collection in MongoDB. I want to index this Data, If I put @Indexed at the top of my entity class, I get this exception:
Code:
Exception in thread "main" org.hibernate.service.jta.platform.spi.JtaPlatformException: Could not obtain JBoss Transactions transaction manager instance
at org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform.locateTransactionManager(JBossStandAloneJtaPlatform.java:52)
at org.hibernate.service.jta.platform.internal.AbstractJtaPlatform.retrieveTransactionManager(AbstractJtaPlatform.java:104)
at org.hibernate.search.backend.impl.EventSourceTransactionContext.isLocalTransaction(EventSourceTransactionContext.java:134)
at org.hibernate.search.backend.impl.EventSourceTransactionContext.registerSynchronization(EventSourceTransactionContext.java:101)
at org.hibernate.search.backend.impl.TransactionalWorker.performWork(TransactionalWorker.java:90)
at org.hibernate.search.event.impl.FullTextIndexEventListener.processWork(FullTextIndexEventListener.java:243)
at org.hibernate.search.event.impl.FullTextIndexEventListener.onPostInsert(FullTextIndexEventListener.java:203)
at org.hibernate.action.internal.EntityInsertAction.postInsert(EntityInsertAction.java:155)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:132)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:275)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1210)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352)
at com.sun.proxy.$Proxy11.flush(Unknown Source)
at hogm.hibernateogm_mongodb.App.main(App.java:53)
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [com.arjuna.ats.jta.TransactionManager]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
at org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform.locateTransactionManager(JBossStandAloneJtaPlatform.java:46)
... 21 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : com.arjuna.ats.jta.TransactionManager
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
... 22 more
my entity class:
Code:
@Entity
@Indexed
public class User{
@Id
@GeneratedValue(generator = "uuid")
private String id;
@Field(index= Index.YES,analyze = Analyze.NO,store = Store.NO)
private String city;
@Field(index= Index.YES, analyze = Analyze.NO)
private int UserID;
and the DAO:
Code:
String[] city={"Berlin","Shiraz","Chemnitz","Teheran","Stutgart","Görlitz",
"Münster","Köln","Isfahan","Losangles","Washington","Paris","Madrid","London",
"Newyork","Sydny","Cairo","Amsterdam","Aachen","Hamburg","Dresden","Leipzig",
"Montreal","Vancouver","Prag","München","Isfahan"};
OgmConfiguration cfgogm=new OgmConfiguration();
cfgogm.configure("hibernate.cfg.xml");
serviceregistry=new ServiceRegistryBuilder().applySettings(cfgogm.getProperties()).buildServiceRegistry();
sessionfactory=cfgogm.buildSessionFactory(serviceregistry);
Session session=sessionfactory.getCurrentSession();
session.beginTransaction();
for(int i=0;i<3;i++)
{
//session.beginTransaction();
Random rd=new Random();
int c=rd.nextInt(27)+0;
int id=rd.nextInt(100000)+10000;
User user=new User();
user.setCity(city[c]);
user.setUserID(id);
session.save(user);
}
session.flush();
session.getTransaction().commit();
System.out.println("Done...");
}
What should I do to solve this exception?