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

    RESTEasy in Seam and lazy-loading exceptions

    Stephane Epardaud Newbie


      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.

      public class RESTFooBean {
       public static class ListOfUsers {
        List<User> users;
        public ListOfUsers(List<User> users){ this.users = 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?