title: Why is my StatelessSession asking for a container transaction?
body: <p>I have a runnable task as follows</p>
  
  <pre><code>@TransactionManagement(TransactionManagementType.BEAN)
  @TransactionAttribute(TransactionAttributeType.NEVER)
  public class Task implements Runnable {
  
      private SessionFactory sessionFactory;
  
      public Task(SessionFactory sessionFactory) {
          this.sessionFactory = sessionFactory;
      }
  
      public void run() {
          StatelessSession session = sessionFactory.openStatelessSession();
          session.beginTransaction();
          // ... the rest is irelevant because beginTransaction launches an exception
  </code></pre>
  
  <p>SessionFactory is supplied by a bean but when I try to begin the transaction, even tough I marked the class as TransactionAttributeType.NEVER, hibernate launches the exception</p>
  
  <pre><code>org.hibernate.TransactionException: Could not register synchronization for container transaction
  </code></pre>
  
  <p>I tried <a href="https://forum.hibernate.org/viewtopic.php?f=1&amp;t=972434" rel="nofollow">this</a> but I only got another problem</p>
  
  <pre><code>org.hibernate.TransactionException: Could not find UserTransaction in JNDI [java:comp/UserTransaction]
  </code></pre>