title: Transactions in Spring / Hibernate / appfuse
body: <p>As a follow up to the question here:  <a href="https://stackoverflow.com/questions/7141032/spring-2-0-annotations-and-ant">Spring 2.0 Annotations and ant</a></p>
  
  <p>We were able to get the annotations working (@Transactional), and also tried manually coding a Transaction.</p>
  
  <p>In both cases, we are getting some problems.  This is an appfuse 1.9.4 project, where we manually upgraded to a newer Hibernate project.  This is using Spring 2.0.</p>
  
  <p>What I'd like to do is to wrap an entire web service in a database "Transaction", so that the entire "call" is atomic.  I understand that the "easiest" way to do this is with @Transactional?</p>
  
  <p>To do so, we added to our class:</p>
  
  <pre><code>import org.springframework.transaction.annotation.Transactional;
  </code></pre>
  
  <p>And then, next to the method (which is public), we did:</p>
  
  <pre><code>@Transactional (readOnly = false, rollbackFor=Exception.class)
  public List processEmployees(List employees){
    ....
  }
  </code></pre>
  
  <p>In to applicationContext-hibernate.xml, I added:</p>
  
  <pre><code>&lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  </code></pre>
  
  <p>Now, when I start Tomcat, I get this lovely error:</p>
  
  <pre><code>[Scheduler] 2011-08-22 12:57:03,032 ERROR [main] ContextLoader.initWebApplicationContext(205) | Context initialization failed
  org.springframework.beans.factory.BeanDefinitionStoreException: Line 153 in XML document from ServletContext resource [/WEB-INF/applicationContext-hibernate.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix "tx" for element "tx:annotation-driven" is not bound.
  Caused by: 
  org.xml.sax.SAXParseException: The prefix "tx" for element "tx:annotation-driven" is not bound.
  </code></pre>
  
  <p>We are using Spring 2.0, but do not have any AOP "configured".</p>
  
  <p>Any ideas?</p>
  
  <p>Alternatively, I'm happy to do this with Transaction.commit(), but going that route throws a message about the transaction never being started.</p>
  
  <p>Thanks!</p>