1 Reply Latest reply on Feb 8, 2010 12:18 AM by Ilya Dyoshin

    Application-Scoped RESTEasy service with EntityManager: EntityManager is closed exception ALWAYS!

    Ilya Dyoshin Novice

      Hello,


      I'm getting some problem with creating Application-scoped RESTEasy service.


      I need it to be statefull, because in one call user starts transaction in another it adds some data,  and in third call it's commited. Actually all logic is in last call. in the lastcall I use entityManager, and my application always dies with entityManager is closed exception?


      Any idea?


      my component in general is like the following:


      @Path("/service")
      @Scope(APPLICATION)
      public class BankService extends EntityController {
      
        @Get("/begin")
        public String begin() {
         ...
         return myTransactionId;
        }
      
        @Get("/add/{transactionId}/{somedata}")
        public String add(@PathParam("transactionId") String transactionId, @PathParam("somedata") String somedata) {
          ...
        }
      
        @Get("/commit/{transactionId}")
        public String commit(@PathParam("transactionId") String transactionId) {
      
          ... 
          getEntityManager().persist(object); // HERE I RECEIVE An EXCEPTION EntityManager isClosed;
          ...
        }
      }