4 Replies Latest reply on Apr 10, 2002 2:12 PM by jessica hekman

    Unable to get Connection because of timed out transaction

    jessica hekman Newbie

      I am testing code which uses many-to-many relationships. Some servlets/JSPs add to these relations, and some just list the related beans. Sometimes, after I have been using them for awhile, I get the following error:

      Find failed: java.sql.SQLException: Unable to get Connection: javax.resource.ResourceException: Could not enlist in transaction on entering meta-aware object!javax.transaction.SystemException: Could not enlist XAResource!javax.transaction.RollbackException: Already marked for rollback

      I am not explicitly using any transactions. Once I get this error, no EJBs work -- none can get a database connection -- until my session times out, after which they start working again.

      I assume there are some implicit transactions going on here, but I don't know why they are timing out.

      Part of my ejb-jar.xml:


      <ejb-relation>
      <ejb-relation-name>Fandom-Recommendation</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>fandom-has-recommendations</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>FandomBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>recommendations</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>recommendation-belongsto-fandom</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>RecommendationBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>fandoms</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>



      Some sample JSP:
      <c:forEach var="recommendation" items="${fandom.recommendations}">

      <a href="<c:out value="${recommendation.url}"/>"><c:out value="${recommendation.title}"/>
      [...]

      The above JSP has thrown this error:

      12:02:08,992 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
      java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout
      at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.doSchedule(QueuedPessimisticEJBLock.java:164)
      at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.schedule(QueuedPessimisticEJBLock.java:137)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:103)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:474)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:307)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker$EntityProxy.invoke(BaseLocalContainerInvoker.java:407)
      at $Proxy32.getUrl(Unknown Source)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.apache.taglibs.standard.lang.jstl.ArraySuffix.evaluate(ArraySuffix.java:309)
      at org.apache.taglibs.standard.lang.jstl.ComplexValue.evaluate(ComplexValue.java:142)
      at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:183)
      at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:143)
      at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:352)
      at org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:109)
      at org.apache.taglibs.standard.tag.el.core.ExprTag.doStartTag(ExprTag.java:137)
      at org.apache.jsp.ListRecommendations$jsp._jspService(ListRecommendations$jsp.java:168)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:326)
      at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:259)
      at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:171)
      at net.arborius.autorec.servlets.ListRecommendations.doGet(ListRecommendations.java:46)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:326)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:595)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1357)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1309)
      at org.mortbay.http.HttpServer.service(HttpServer.java:744)
      at org.jboss.jetty.Jetty.service(Jetty.java:530)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:743)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:916)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:758)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:145)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:287)
      at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:715)
      at java.lang.Thread.run(Thread.java:484)

      I am at a loss. I have even tried explicitly beginning and commiting UserTransactions; no difference.

      Please help!

      Thanks,
      Jessica