title: Spring Transactions not rolling back on Exception (Oracle JNDI datasource)
body: <p>I am using annotation based transactions in a Spring MVC 3.1 project, and my transactions are not being rolled back when an exception is thrown.</p>
  
  <p>Here is my Service code</p>
  
  <pre><code>
  @Service
  public class ImportService {
  
      @Autowired
      ImportMapper importMapper;
  
      @Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED, rollbackFor=Throwable.class)
      public void processImport() throws ServiceException, DatabaseException {
          iImport import = new Import();
  
          createImport(import);
  
          throw new ServiceException("");         
      }
  
      @Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED, rollbackFor=Throwable.class)
      private void createImport(Import import) throws DatabaseException {
          try {
              importMapper.createImport(eventImport);
          } catch (Exception e) {
              throw new DatabaseException(e);
          }
      }
  </code></pre>
  
  <p>So, hopefully, the createImport method should be rolled back after the exception is thrown.  But unfortunately it's not.</p>
  
  <p>I am defining my datasource in the server context.xml</p>
  
  <pre><code>&lt;Resource name="datasource.import" auth="Container" type="javax.sql.DataSource"
             maxActive="100" maxIdle="30" maxWait="10000"
             username="user" password="password" driverClassName="oracle.jdbc.driver.OracleDriver"
             url="jdbc:oracle:thin:@INFO" /&gt;
  </code></pre>
  
  <p>And I'm looking it up with JNDI:</p>
  
  <pre><code>&lt;jee:jndi-lookup id="dataSource" jndi-name="datasource.import"/&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven /&gt;
  </code></pre>
  
  <p>I'm using an Oracle database, and the JDBC spec says that auto commit is true by default.  I thought that if I set it to false explicitly that would help, but I can't figure out how to do that. </p>
  
  <p>Is there any way to get rollbacks working, while looking up your Oracle datasource by JNDI.</p>