I'm using: Spring 4.2.1 Hibernate 5.0.1 Hibernate Search 5.5.0
I have an existing Spring MVC project using JPA 2.1 with annotation-based config that I'm trying to integrate Hibernate Search into. This is the first time I've used Hibernate Search, so maybe I'm missing something obvious. When running in Tomcat, I get an exception that says "org.hibernate.SessionException: Session is closed!" any time I call .getResultList() on a FullTextQuery. This is in a method that is annotated with @Transactional, and I have no problems otherwise using an EntityManager or repositories to modify the database. I'm using Spring's transaction management, so obviously I don't have any manual control over them.
I've made a relatively simple application to demonstrate the issue: https://github.com/pjreed/hibernate-search-test
To see the issue, run: mvn tomcat7:run
Then access this page to add some dummy accounts: http://localhost:8080/test/addusers Then try a search, which will log the exception to the console: http://localhost:8080/test/search?number=1
The class at com.example.test.TestController contains the methods for adding users and searching.
I've Googled around for a while and read through the documentation, and I have no idea what's going on. It doesn't seem to matter whether the method has @Transactional or not. More peculiarly, I put together a unit test that you can run with "mvn test" that goes through the MVC methods... and it seems like it works fine. I have no idea what the test configuration could be doing differently that makes it work.
Any suggestions?
|