-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: "Session is closed" exception in FullTextQuery.getResultList
PostPosted: Wed Sep 30, 2015 12:10 pm 
Newbie

Joined: Wed Sep 30, 2015 11:48 am
Posts: 1
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?


Top
 Profile  
 
 Post subject: Re: "Session is closed" exception in FullTextQuery.getResultList
PostPosted: Thu Oct 01, 2015 3:00 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

Any chance that you further simplify that example? A plain unit test would be perfect, ideally even without Spring, but I suppose that's a needed part of the picture. I suppose something with the Spring configuration of TX control is not right, but to actually tell a simpler reproducer without Tomcat and web app specifics would be very helpful.

Cheers,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.