title: Spring/Hibernate Exception: createCriteria is not valid without active transaction
body: <p>I spent few days on an spring-hibernate-transaction issue. I create a simple webservice with jaxws + spring + hibernate, it works fine but when I call a web methode which use a transactional bean spring threw the following error:</p>
  
  <pre><code>21 sept. 2011 14:29:29 com.sun.xml.ws.server.sei.EndpointMethodHandler invoke
  GRAVE: org.hibernate.HibernateException: createCriteria is not valid without active transaction
  </code></pre>
  
  <p>I seems the transaction has been started ... but something wrong  happened.</p>
  
  <pre><code>[jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Creating new transaction with name [com.cellfish.mediadb.ws.encoder.MediaDBFeeds.testTransaction]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly; ''
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Opened new Session [org.hibernate.impl.SessionImpl@26b20a31] for Hibernate transaction
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@26b20a31]
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Exposing Hibernate transaction as JDBC transaction [jdbc:mysql://xxxxxxxx, MySQL-AB JDBC Driver]
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Found thread-bound Session [org.hibernate.impl.SessionImpl@26b20a31] for Hibernate transaction
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Participating in existing transaction
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Participating transaction failed - marking existing transaction as rollback-only
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Setting Hibernate transaction on Session [org.hibernate.impl.SessionImpl@26b20a31] rollback-only
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Initiating transaction rollback
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Rolling back Hibernate transaction on Session [org.hibernate.impl.SessionImpl@26b20a31]
  [jmedia] 21 sept. 2011 14:29:29 [http-8080-1] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Closing Hibernate Session [org.hibernate.impl.SessionImpl@26b20a31] after transaction
  21 sept. 2011 14:29:29 com.sun.xml.ws.server.sei.EndpointMethodHandler invoke
  </code></pre>
  
  <p>Here my applicationContext :</p>
  
  <pre><code>&lt;context:annotation-config/&gt;
  
      &lt;!-- List of packages managed by Spring --&gt;
      &lt;context:component-scan base-package="..." /&gt;
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
          &lt;property name="url" value="jdbc:mysql://xxxx"/&gt;
          &lt;property name="username" value="xxx"/&gt;
          &lt;property name="password" value="xxx"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
          &lt;property name="packagesToScan" value="xxxx"/&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
      &lt;bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>And the hibernate.cfg.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;!-- a SessionFactory instance listed as /jndi/name --&gt;
      &lt;session-factory&gt;
  
          &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.format_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.connection.pool_size"&gt;1&lt;/property&gt;
  
          &lt;property name="hibernate.jdbc.batch_size"&gt;20&lt;/property&gt;
          &lt;!-- Bind the getCurrentSession() method to the thread. --&gt;
          &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
          &lt;property name="hibernate.cache.provider_class"&gt;net.sf.ehcache.hibernate.SingletonEhCacheProvider&lt;/property&gt;
          &lt;property name="hibernate.cache.use_second_level_cache"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.cache.use_query_cache"&gt;true&lt;/property&gt;
  
          &lt;!-- Lucene Search --&gt;
          &lt;property name="hibernate.search.default.directory_provider"&gt;org.hibernate.search.store.RAMDirectoryProvider&lt;/property&gt;
  
      &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>I deployed this webapp on tomcat6.
  I hope can you help me to resolve that issue.</p>
  
  <p>Cheers</p>