title: Transaction not successfully started
body: <pre><code>public void saveSoDtls(SoDtls soDtls){    
              try {
                   session = HibernateSessionFactory.getSessionFactory()
                          .openSession();
  
                  session.beginTransaction();
  
                   session.save(soDtls);
  
                  session.getTransaction().commit();
  
                 //Creating pdf file (itext) using SoDtls object 
              } catch (HibernateException hex) {
                  session.getTransaction().rollback(); 
                  throw hex;
              }catch (Exception ex) {
                  session.getTransaction().rollback();  //------&gt; getting error at this line
                  throw ex;
              }finally{
                  if(session != null){
                      session.close();
                  }
              }
  }
  </code></pre>
  
  <ol>
  <li>I want to sync both commit and creating file. If there is any error while creating file then there should be rollback of the transaction.</li>
  <li>If there is any error while committing transaction then file should not be created. (This scenario working fine)</li>
  </ol>
  
  <p>But first scenario is not working fine as I am getting transaction not successfully started while rollbacking if there is error while creating pdf file.</p>