Announcement Announcement Module
Collapse
No announcement yet.
SpringMVC - Session is closed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SpringMVC - Session is closed

    I'm just not getting it. I'm trying to learn SpringMVC, thought I was doing it correctly, but I keep getting a " Session is Closed" exception when I attempt to call a Repository object from a Controller object. Any enlightenment would be highly appreciated.


    Code:
    **Repository
    public class UserServiceImpl implements UserService {
    
       **PersistenceContext
       private EntityManager entityManager;
    
       **SuppressWarnings("unchecked")
       public List<User> getUsers() {
          Query query = entityManager.createNamedQuery("User.findUsers");
          return query.getResultList();
       }
    }
    Code:
    **Controller
    public class WelcomeController {
       
       **Autowired (required = true)
       private UserService userService;
    
       **RequestMapping("/list2.do")
       public ModelMap getUsers() {
          
          List<User> users = userService.getUsers();
          System.out.println("NUM USERS: " + users.size());
          return null;
          
       }
    }

    All my server side JUnit tests work as expected ... everything works but this
    and the error is ...

    org.springframework.orm.hibernate3.HibernateSystem Exception: Session is closed!; nested exception is org.hibernate.SessionException: Session is closed!


    Help!

  • #2
    I also have the same issue. I tried to solve the issue using the openSessionViewInterceptor without any result.

    Comment


    • #3
      Session problem

      Me2, I encounter the same problem.

      Comment

      Working...
      X