users@glassfish.java.net

Re: Container Managed Transaction and Hibernate Search

From: <glassfish_at_javadesktop.org>
Date: Mon, 03 Sep 2007 02:07:18 PDT

Ok thanks it works when using CMTTransactionFactory but I have another similar problem...

My ejb are web services that make uses of web services handlers. One of this handler needs to persist data. The handler is called after the web service execution, and thus, outside of the CMT session.
So I have to begin a new transaction outside of the CMT session.
I tried with the following code :
Session session = HibernateSessionFactory.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();

try {
   LoggingService.getInstance().create(log);
   if (tx != null) {
      tx.commit();
    }
} catch (Exception e) {
   if (tx != null) {
      tx.rollback();
   }
} finally {
   session.close();
}

With CMTTransactionFactory or JTATransactionFactory I have the same error :
javax.naming.NameNotFoundException: [i]Lookup of java:comp/UserTransaction not allowed for Container managed Transaction beans[/i]

Is my code correct?
[Message sent by forum member 'will_mad' (will_mad)]

http://forums.java.net/jive/thread.jspa?messageID=233632