3 Replies Latest reply on Oct 14, 2009 1:07 PM by Nikolay Elenkov

    EntityManager transaction in a Seam managed Servlet

    Giovanni Miano Newbie

      Hi guys,
      I create a servelet managed by seam (web:context-filter), something like:



      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      
      EntityManager entityManager = (EntityManager)Component.getInstance("entityManager");|
      
      entityManager.persist(a);
      
      entityManager.flush;
      }




      I can easily fetch object using entityManager.find, createQuery etc.. but when I try to persist I get the following exception.


      TransactionRequiredException: no transaction is in progress


      I tried also entityManager.getTransaction().begin() and I get the same result.


      I can even immagine why is that but how do I find a work-around ?


      Thanks