My first wild guess leading to a
HibernateException: contains is not valid without active transaction
exception was my use of annotated Hibernate classes together with additional constraints in Grails, but Graeme figured out that it was the current session context i configured in hibernate.cfg.xml like so:
I used this fragment for various JUnit test and in one case in a J2SE application where the same hibernate classes are needed. Together with a JTA Manager, this fragment is not needed and in case of Grails it has to go.
To run my tests i added the following statement right before opening my session:
final Properties nonJtaEnv = new Properties(); nonJtaEnv.put("hibernate.current_session_context_class", "thread"); sessionFactory = new AnnotationConfiguration().configure("hibernate.cfg.xml").addProperties(nonJtaEnv).buildSessionFactory();