0 Replies Latest reply on Jun 5, 2008 4:41 PM by Conny Svensson

    No transaction in progress

    Conny Svensson Newbie

      I'm using Seam 2.0.2SP1 and GWT 1.5RC1. I'm having some problems merging entities. I get an TransactionException No transaction in progress. I've done a project in Seam before using the regular JSF presentation layer but now I'm moving to GWT. Is there anything special I need to setup for persistence management to get it to work? Querying the backend works fine but not merging or persisting. Here is my code:

      public class SaveEmployeeHandler extends RpcEventHandler<SaveEmployee, RpcEntityResult> {
          @Logger Log log;
          @In EntityManager entityManager;
          protected RpcEntityResult doHandle(SaveEmployee request) throws RpcException {
              log.info("Saving employee with id: #0", request.getEntity().getId());
              // Updated entity from client
              Employee clientEmp = (Employee) request.getEntity();
              // Get attached entity from backend
              Employee dbEmp = (Employee) entityManager.find(Employee.class, clientEmp.getId());
              // Merge client and backend entities (this should be done with hibernate4gwt)
              try {
                  dbEmp = entityManager.merge(dbEmp);
              } catch (Exception ex) {
                  throw new RpcException(ex);
              return new RpcEntityResult(dbEmp);

      It crashes on the flush operation. The commented lines are things I've tried to start a transaction but haven't worked. I'm currently using the following code and it works but it feels like it shouldn't be necessary, it's not the regular Seam way.

      Session session = (Session) entityManager.getDelegate();

      Anyone with an idea why the Seam container doesn't start a transaction automatically for me as it should? I read somewhere that it starts the transaction in the JSF lifecycle but I'm not using JSF. I have marked the method as Transactional so that should take care of it, right?