You can enable Hibernate statistics to see the number of open and closed sessions: hibernateConfiguration.setProperty(Environment.GENERATE_STATISTICS, "true") Then use SessionFactory.getStatistics() to view open and closed sessions. This should tell you if you are having sessions.
Finding out where the leak is coming from is another problem. I did this by centralizing all the code to get the session, and then saving the stack trace every time I open the session (downstream) and deleting it when the session is closed. Periodically review the list of open sessions, and depending on which of them remain, leaked. Profiling tools can make this easier if you can reproduce the leak in a controlled environment.
source share