-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Could not obtain JBoss Transactions transaction manager
PostPosted: Wed Aug 28, 2013 4:40 am 
Beginner
Beginner

Joined: Thu Jul 11, 2013 7:58 am
Posts: 22
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?


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Wed Aug 28, 2013 7:20 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I think you are missing a dependency on the classpath.
You can try to add
jbossjta-4.16.4.Final.jar http://mvnrepository.com/artifact/org.jboss.jbossts/jbossjta/4.16.4.Final


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Wed Aug 28, 2013 7:28 am 
Beginner
Beginner

Joined: Thu Jul 11, 2013 7:58 am
Posts: 22
thnak you for your answer.

If I add
Code:
<property name=" hibernate.search.indexing_strategy">manual</property> 


to my hibernate.cfg.xml I dont see this error, but another problem is, that I want to do Indexing automatically and not manual.
now I am using the following code to index data:

Code:
OgmConfiguration cfgogm=new OgmConfiguration();
        cfgogm.configure("hibernate.cfg.xml");
        serviceregistry=new ServiceRegistryBuilder().applySettings(cfgogm.getProperties()).buildServiceRegistry();
        sessionfactory=cfgogm.buildSessionFactory(serviceregistry);         
        Session session=sessionfactory.openSession();
        session.beginTransaction();
        FullTextSession fullTextSession = Search.getFullTextSession(session);
        fullTextSession.createIndexer(User.class).startAndWait();


but I get this exception:
Code:
HSEARCH000116: Unexpected error during MassIndexer operation
java.lang.NullPointerException


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Wed Aug 28, 2013 7:55 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I cannot help you if you don't give me more details, can you post the stacktrace of the NullPointerException.

I don't also understand if you have the library i've suggested on the classpath (jbossjta) this is an optional library if you are using a container but this does not seem to be your case.
I suspect that this NullPointer is caused by the same issue.


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Wed Aug 28, 2013 8:08 am 
Beginner
Beginner

Joined: Thu Jul 11, 2013 7:58 am
Posts: 22
thank you so much for your quick reply

I added this this jar to my depandancy but the problem remains. The stacktrace is:

Code:
ERROR: HSEARCH000058: HSEARCH000116: Unexpected error during MassIndexer operation
java.lang.NullPointerException
   at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.<init>(AbstractStatementProxyHandler.java:57)
   at org.hibernate.engine.jdbc.internal.proxy.PreparedStatementProxyHandler.<init>(PreparedStatementProxyHandler.java:50)
   at org.hibernate.engine.jdbc.internal.proxy.ProxyBuilder.buildPreparedStatement(ProxyBuilder.java:187)
   at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.postProcess(ConnectionProxyHandler.java:167)
   at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:139)
   at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
   at com.sun.proxy.$Proxy16.prepareStatement(Unknown Source)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1720)
   at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1697)
   at org.hibernate.loader.Loader.doQuery(Loader.java:832)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293)
   at org.hibernate.loader.Loader.doList(Loader.java:2382)
   at org.hibernate.loader.Loader.doList(Loader.java:2368)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2198)
   at org.hibernate.loader.Loader.list(Loader.java:2193)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:122)
   at org.hibernate.internal.StatelessSessionImpl.list(StatelessSessionImpl.java:657)
   at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
   at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396)
   at org.hibernate.search.batchindexing.impl.IdentifierProducer.loadAllIdentifiers(IdentifierProducer.java:130)
   at org.hibernate.search.batchindexing.impl.IdentifierProducer.inTransactionWrapper(IdentifierProducer.java:115)
   at org.hibernate.search.batchindexing.impl.IdentifierProducer.run(IdentifierProducer.java:96)
   at org.hibernate.search.batchindexing.impl.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:135)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:722)


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Wed Aug 28, 2013 8:39 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Do you still have the ClassNotFoundException if you remove the manual indexing?
Could you also put the project on github so that I can take a look at it?


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Wed Aug 28, 2013 10:02 am 
Beginner
Beginner

Joined: Thu Jul 11, 2013 7:58 am
Posts: 22
Hi Davide80, thank you for your post
actually I dont have this error, but I have another error:
Code:
createCriteria is not valid without active transaction


hier you can find my code in Github
https://github.com/bastan/MongoDB-OGM


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Thu Aug 29, 2013 9:18 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I've downloaded the project and when I run tha main app I don't have any exception.
Objects are also persisted in the DB.

About the MassIndexer you may have found a bug. I'm investigating aboiut it.
To make it work you should run the code after you have closed the session and outside a transaction.

I've imported the project in eclipse.


Top
 Profile  
 
 Post subject: Re: Could not obtain JBoss Transactions transaction manager
PostPosted: Mon Sep 02, 2013 11:21 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Davide: this issue was resolved. See also https://forum.hibernate.org/viewtopic.php?f=9&t=1028342

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.