5 Replies Latest reply on Aug 18, 2009 10:21 AM by fromage

    RESTEasy in Seam and lazy-loading exceptions

    fromage

      Hello,


      I'm using RESTEasy with Seam and when I return a resource with a lazy-loaded collection, the JAXB provider (which does the serialization) generates a lazy-loading exception because the Hibernate session has been closed.


      @Path("/")
      @Name("RESTFoo")
      public class RESTFooBean {
      
       @XmlRootElement("users")
       public static class ListOfUsers {
        @XmlElement("user")
        List<User> users;
        public ListOfUsers(List<User> users){ this.users = users; }
       }
      
       @GET
       @Path("/users")
       public ListOfUsers getUsers(){
        // load the list of users, each has a lazy-loading collection
        return new ListOfUsers(users);
       }
      }
      



      Is there a way for Hibernate sessions (or Seam-managed persistence sessions) to stay open during the entire RESTEasy dispatch call and not just in the Seam component?