0 Replies Latest reply on Sep 8, 2004 5:25 PM by Julien Martin

    Problems with container managed transaction

    Julien Martin Expert

      Hello,
      1. I have a jsp which calls a stateless session facade
      2. My stateless session facade itelf calls a findbyprimarykey finder of an entity bean
      3. My entity bean has a collection of another entity bean

      A . When I set the trans attribute of my session facade methods to Required and the trans attribute of my entity beans as Mandatory I get the following exception:

      java.lang.IllegalStateException: A CMR collection may only be used within the transction in which it was created
       org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.getIdList(RelationSet.java:66)
       org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.access$000(RelationSet.java:32)
       org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet$1.<init>(RelationSet.java:355)
       org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.iterator(RelationSet.java:353)
       org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(Unknown Source)
       org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(Unknown Source)
       org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(Unknown Source)
       javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(Unknown Source)
       org.apache.jsp.displayItem_jsp._jspx_meth_c_forEach_0(displayItem_jsp.java:282)
       org.apache.jsp.displayItem_jsp._jspx_meth_f_view_0(displayItem_jsp.java:157)
       org.apache.jsp.displayItem_jsp._jspService(displayItem_jsp.java:97)
       org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
       org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
       com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
       com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
       com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
      


      B. When I set the trans attribute of my session facade methods to Required and the trans attribute of my entity beans as Required I get the same exception as above.

      C. When I set all trans attributes at supports I get the following exception:

      org.apache.jasper.JasperException: RuntimeException; CausedByException is:
       A CMR collection may only be used within the transction in which it was created
       org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
       org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
       com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
       com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
       com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
      root cause
      javax.ejb.EJBException: RuntimeException; CausedByException is:
       A CMR collection may only be used within the transction in which it was created
       org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:357)
       org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
       org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
       org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:522)
       org.jboss.ejb.Container.invoke(Container.java:871)
       org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:394)
       org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
       $Proxy133.getAverageGrade(Unknown Source)
       com.softwareag.test_guide.ejb.util.PGConvertUtil.convertPGEstablishmentLocalIntoPGEstablishmentTO(PGConvertUtil.java:20)
       com.softwareag.test_guide.sessionFacadeEJB.PGSessionFacadeBean.getEstablishmentFromId(PGSessionFacadeBean.java:44)
       sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       java.lang.reflect.Method.invoke(Method.java:324)
       org.jboss.invocation.Invocation.performCall(Invocation.java:345)
       org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
       org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
       org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
       org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
       org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
       org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
       org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:342)
       org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
       org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
       org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
       org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
       org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:625)
       org.jboss.ejb.Container.invoke(Container.java:871)
       org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:394)
       org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:82)
       $Proxy151.getEstablishmentFromId(Unknown Source)
       com.softwareag.test_guide.web.temp.PGBusinessDelegate.getEstablishmentFromId(PGBusinessDelegate.java:23)
       com.softwareag.test_guide.web.tags.PGSetEstablishmentTag.doStartTag(PGSetEstablishmentTag.java:27)
       org.apache.jsp.displayItem_jsp._jspService(displayItem_jsp.java:91)
       org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
       org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
       com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
       com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
       com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
      note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27-dev logs.
      
      Apache Tomcat/5.0.27-dev
      
      




      What I am getting wrong? Any help welcome.

      Julien Martin.