0 Replies Latest reply on Jul 22, 2007 11:15 AM by Davy De Winter

    javax.transaction.RollBackException when calling session-bea

    Davy De Winter Newbie

      Hi,

      I'm experiencing antoher problem when trying to call a method of a stateless session-bean from a servlet. The session-bean has the following method:

      
      @Stateless (mappedName="ArticleManager")
      public class ArticleManager implements ArticleManagerRemote, ArticleManagerLocal {
       @PersistenceContext (unitName="texaco",type=PersistenceContextType.TRANSACTION) EntityManager em;
      
       @TransactionAttribute(TransactionAttributeType.REQUIRED)
       public Article testArticles(int i){
       Article article=em.find(Article.class, 1);
       System.out.println("*********** Article name" + article.getArticle_name());
       return article;
       }
      }
      
      


      This method is called from the servlet; the session-bean is injected:

      public class TestServlet extends HttpServlet {
       private @EJB ArticleManagerLocal artman;
       public void doGet(HttpServletRequest req, HttpServletResponse res)
       throws ServletException, IOException{
       try {
       Article article=artman.testArticles(1);
       PrintWriter out=res.getWriter();
       out.print("<HTML>");
       out.print(article.getArticle_name());
       out.print("</HTML>");
       out.println("Hello, world said davy!");
       out.close();
       } catch (Exception ex){
       System.out.println(ex.printStackTrace());
       }
       }
      }
      


      When I try to call the testArticles method, I'm fetching an article from the underlying mysql-database. In the testArticles()-method itself, the name of the article with id="1" is printed correctly, but in the final stage of the method-call, I get the following error-message:

      2007-07-22 17:05:28,906 INFO [STDOUT] *********** Article namecoca cola
      2007-07-22 17:05:28,906 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
      2007-07-22 17:05:28,921 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
      2007-07-22 17:05:28,968 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] mark transaction for rollback
      2007-07-22 17:05:28,968 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** closing entity managersession **************
      2007-07-22 17:05:29,031 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/texaco_webapp].[hello]] Servlet.service() for servlet hello threw exception
      java.lang.RuntimeException: javax.transaction.RollbackException
       at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
      


      As one can see: the name of the article itself is fetched correct, but as soon as the article is returned to the servlet, I get that horrible javax.transaction.RollbackException. Also interesting might be the "root cause" of the problem:

      javax.transaction.RollbackException
       com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1192)
       com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:134)
       com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87
      etc.
      


      I use MySQL 5.0.41, Jboss-5.0.0-Beta2 and mysql-connection-java-5.0.6. Is it possible the warning at startup: The locking scheme is NONE instead of
      READ_COMMITTED is set, has something to do with this? And in which configuration-file can I change that setting eventually?

      Once again,
      thanks for possible answers!

      Davy.