0 Replies Latest reply on Aug 10, 2006 5:05 AM by jklanka

    A CMR collection may only be used within the transction in w

    jklanka Newbie

      I have two Entoty Beans (CNTReport and CNTReportAct)
      1. CNTReportBean having following XDoclet reference
      * @ejb.bean name="CNTReport"
      * display-name="Name for CNTReport"
      * description="Description for CNTReport"
      * jndi-name="ejb/CNTReport"
      * local-jndi-name="ejb/CNTReportLocal"
      * type="CMP"
      * transaction-type="Container"
      * cmp-version="2.x"
      * primkey-field="cnt_id"
      * view-type="both"
      * schema = "CNTReportSchema"
      *
      * @ejb.transaction
      * type="Required"

      *
      * @ejb.finder
      * signature="java.util.Collection findAllContacts()"
      * query="SELECT OBJECT(c) FROM CNTReportSchema AS c"
      ...
      ...
      ....

      And also CMR Field defined like below
      /**
      * Getter for CMR Relationship
      *
      * @ejb.interface-method view-type="local"
      * @ejb.relation name = "CNTReport-to-CNTReportAct"
      * role-name = "CNTReport-has-Many-CNTReportAct"
      * target-ejb = "CNTReportAct"
      * target-role-name = "CNTReportAct-has-one-CNTReport"
      * target-multiple = "no"
      * @ejb.transaction
      * type="Required"
      * @return
      */


      public abstract java.util.Collection getActions();

      /**
      * Setter for CMR Relationship
      *
      * @ejb.interface-method view-type="local"
      */
      public abstract void setActions(java.util.Collection value);



      1. CNTReportActBean having following XDoclet reference

      /**
      * @ejb.bean name="CNTReportAct"
      * display-name="Name for CNTReportAct"
      * description="Description for CNTReportAct"
      * jndi-name="ejb/CNTReportAct"
      * local-jndi-name="ejb/CNTReportActLocal"
      * type="CMP"
      * transaction-type="Container"
      * cmp-version="2.x"
      * primkey-field="id"
      * view-type="both"
      * schema = "CNTReportActSchema"
      *
      * @ejb.transaction
      * type="Required"
      *
      *
      And also CMR Field defined like below
      /**
      * Getter for CMR Relationship
      *
      * @ejb.interface-method view-type="local"
      * @ejb.relation name = "CNTReport-to-CNTReportAct"
      * role-name = "CNTReportAct-has-one-CNTReport"
      * target-ejb = "CNTReport"
      * target-role-name = "CNTReport-has-Many-CNTReportAct"
      * target-multiple = "yes"
      * @jboss.relation fk-column="cnt_id"
      * related-pk-field="cnt_id"
      * @ejb.transaction
      * type="Required"
      */
      public abstract com.contactreport.CNTReportLocal getContactReport();

      /**
      * Setter for CMR Relationship
      *
      * @ejb.interface-method view-type="local"
      */
      public abstract void setContactReport(com.contactreport.CNTReportLocal value);


      I am using the following codes in the Servlet to Access the Contact Reports
      Collection cntReportDatas=null;
      try {
      cntReportDatas = home.findAllContacts();
      } catch (Exception e) {out.print(e);}
      req.setAttribute("cntReportDatas",cntReportDatas);


      Now the cntReportDatas is forwared to JSP page and read. It is working fine. But when I call the getActions() method it gives the following error

      java.lang.IllegalStateException: A CMR collection may only be used within the transction in which it was created


      I went through so many forums and says that
      "trying to access that CMR in a 'java-bean' which is NOT in the same transaction.

      ==
      I am running this CMP in JBOSS 4.0.2.


      Please help on this