8 Replies Latest reply on Feb 21, 2012 4:42 PM by ole .

    Seam3 REST application and EntityManager

    ole . Newbie



      I have a REST and a normal web application using Seam 3.2. I'm using a stateless bean to manage all persistence operations.


      @Stateless(name="UserHelper", mappedName="UserHelper")
      public class UserHelper implements Serializable{
          private EntityManager em;
           * Add a customer to the service database.
           * @param customer
           * @return
          public boolean addUser(User user) {
              try {
                  return true;
              } catch (Exception e) {
                  return false;
      private UserHelper userHelper(){
              try {
                  return InitialContext.doLookup("java:global/core/UserHelper");
              } catch (NamingException e) {
              return null;


      This is properly working if I'm using this helper class in a managed bean. The problem is that I cannot persist anything by calling e.g. the addUser method from one of my REST classes.


      public class CustomerManager implements Serializable{
          public String hello() throws NamingException{
              Customer cust = new Customer();
              return "Hello";




      I get a log output like this:


      INFO: Hibernate: select nextval ('hibernate_sequence')

      INFO: Hibernate: insert into Users (city, countWrongPin, country, email, firstname, houseNo, isBlocked, lastname, phone, pin, state, street, zip, DTYPE, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'Customer', ?)


      But it is not persisted and I dont know why?! As already mentioned this is properly working if I call a method of the userHelper from one of my managed beans.


      Any ideas what I'm doing wrong?


      The REST jersey app is also starting properly:


      INFO: CDI support is enabled

      INFO: GlobalStatsProvider registered

      INFO: Initiating Jersey application, version 'Jersey: 1.9.1 09/14/2011 02:05 PM'

      INFO: Instantiated the Application class my.app.ejb.rest.RESTApplication