2 Replies Latest reply on Jan 5, 2013 10:30 AM by Ersin Canli

    JBoss AS 7 Support for XDoclet tag @jboss.method-attributes needed

    Ersin Canli Newbie

      Hello,

       

      we are migrating from JBoss AS 4.0.5 to JBoss AS 7.1.3.

      We have a CMP Entity Bean (EJB 2.1) with a 1:n/n:1 relation (java.util.Set<ObjectXYZ>).

      When we load the Entity outside of a transaction (for example by calling homeInterface.findByPrimaryKey(4711) and want to iterate over the relation "java.util.Set..." for example from a struts action we get the following Exception in JBoss AS 7.

      "A CMR collection may only be used within the transaction in which it was created".

       

      The Entity ist configured via XDoclet annotations/tags.

      So we have the tag @jboss.method-attributes pattern = "get*" read-only = "true", which results to

      <entity>

               <ejb-name>....</ejb-name>

               <configuration-name>CMP 2.x and Cache</configuration-name>

       

              <method-attributes>

                  <method>

                    <method-name>get*</method-name>

                    <read-only>true</read-only>

                  </method>

              </method-attributes>

       

            </entity>

      in jboss.xml.

      In JBoss 7 AS the jboss.xml is not supported.

       

      1. Question: How can I tell the getter-methods of my entity to be read-only in JBoss AS 7 ? Otherwise I will get the above Exception with the relation !

      2. Querstion: How is it possible to deploy/configure/run a CMP Entity Bean (EJB 2.1) with a CMR without a transaction in JBoss AS 7.

       

      Thanks.

      Ersin.

        • 1. Re: JBoss AS 7 Support for XDoclet tag @jboss.method-attributes needed
          Wolf-Dieter Fink Master

          Hi Ersin,

           

          If you load a collection via CMR the method call of 'Collection get....' and the iteration must be in the same transaction. This is in AS4.3 and AS5, maybe in 4.0 it was different

           

          the jboss.xml is replaced by jboss-ejb3.xml which is a different structure, you may have a look into the {jboss}/docs/schema for this.

           

          Also in AS7 there are several issues with EJB2 and CMP configuration and behavior. Several people are working on that. I hope that we can provide commits in AS7.1 and AS7.2 branch.

          • 2. Re: JBoss AS 7 Support for XDoclet tag @jboss.method-attributes needed
            Ersin Canli Newbie

            Hi Wolf-Dieter,

             

            thank you very much for the quick response.

            Up to now, I couldn't find a way to configure calls to the getter methods of a CMP Entity Bean (EJB2.1) read-only.

            I have looked into the schemas for jboss-ejb3.xml and ejb-jar.xml and couldn't find any support for my problem.

            In JBoss AS 4/5/6 we had the jboss.xml.

            We don't want to run a load-anything-method with a CMR call in a EJB transaction, because it's just a read, without a write/update operation.

            I think, there should not be a need for a transaction in this szenario (performance issues).

            So, we need something like

            <entity>

                 ...

                    <method-attributes>

                        <method>

                          <method-name>get*</method-name>

                          <read-only>true</read-only>

                        </method>

                    </method-attributes>

            </entity>

            Otherwise, we get the following exception, when we access the CMR collection.

            "A CMR collection may only be used within the transaction in which it was created".

             

            Any idea ?

             

            Ersin