0 Replies Latest reply on Jan 15, 2006 11:46 AM by chelaru.viorel

    no transaction is in progress in Schedulable

      hi all,
      i'm new in ejb, and i have a problem :

      in a class where i implement interface Schedulable.... in the perform() method i write this code :
      UserTransaction ut = (UserTransaction)initCtx.lookup("UserTransaction");
      ut.begin();
      emi.persist(new RssItemBean());
      ut.commit();

      i got emi like this :
      EntityManagerFactory emf=Persistence.createEntityManagerFactory("em");emi=emf.getEntityManager();

      and i get this exception :
      javax.persistence.TransactionRequiredException: no transaction is in progress
      at org.hibernate.ejb.AbstractEntityManagerImpl.checkTransactionActive(AbstractEntityManagerImpl.java:123)
      at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:128)
      at services.schedulables.SchedulesForRssWorker.run(SchedulesForRssWorker.java:221)

      and i know that this exception is thrown because i use the emi outside an persistence context but how can i get the persistence context ?

      thanks,
      chelaru.viorel