6 Replies Latest reply on Nov 25, 2008 12:04 PM by mwringe

    Transaction Demarcation and JBoss AOP 2.0

    mwringe

      Transaction Demarcation (see http://www.jboss.org/community/docs/DOC-9034) used to work with an older CR of AOP 2.0 (the aop CR17 used in JBoss AS 5.0.0.CR2) but it doesn't seem to work anymore with more with the 2.0.GA.

      Has this feature been removed or need to be called in a different manner? The documentation for the 2.0.GA doesn't even mention it anymore.

        • 1. Re: Transaction Demarcation and JBoss AOP 2.0
          mwringe

          nobody knows how this is suppose to be handled now?

          • 2. Re: Transaction Demarcation and JBoss AOP 2.0
            flavia.rainone

            It looks like this functionality has beem moved to the jboss-transaction-aspects.jar, located in the server/*/lib of JBoss AS 5.

            I don't have more details on this, as Kabir is probably the one who moved those aspects to the server. He is currently on vacation.

            So, try that jar and let me know if this works for you.

            • 3. Re: Transaction Demarcation and JBoss AOP 2.0
              mwringe

              Ok, the issue is that in JBoss AS5 parts of AOP are disabled unless you set useBaseXml to true in conf/bootstrap/aop.xml

               <!-- By default the deployment of the aspects contained in
               ../deployers/jboss-aop-jboss5.deployer/base-aspects.xml
               are not deployed. To turn on deployment uncomment this property -->
               <property name="useBaseXml">true</property>
              


              • 4. Re: Transaction Demarcation and JBoss AOP 2.0
                mwringe

                Actually, setting the useBaseXml to true doesn't help in all situations.

                The problem now is that the transaction manager is not started in the begining of the server startup, so in some situations aop will be trying to access the transaction manager before it even starts and will fail.

                Which brings me back to my original question, it looks like transactions will no longer be supported in the same way as it has been in past versions.

                Is transaction support going to be removed, or is there going to be a different way of using it?

                • 5. Re: Transaction Demarcation and JBoss AOP 2.0
                  mwringe

                  A more details description of the issue in the hope that someone will have an answer:

                  If an class is specified through aop to have a transaction requirement (http://www.jboss.org/community/docs/DOC-9034) when aop alters the class it will change the constructor. This change to the constructor will cause the class to search for the constructor when its created, and will fail if the constructor is not found.

                  If this class is an mbean and specified in SAR's jboss-service.xml, when the sar is being deployed it will create the class before even looking at any dependencies for the class. So adding jboss:service=TransactionManager doesn't do any good if the class requires the transaction manager when its constructed.

                  In JBoss AS5, the transaction manger is no longer started at startup and gets deployed after SARs are deployed.

                  So, if a SAR uses aop for transaction demarcation for an mbean specified in jboss-service.xml on JBoss AS5, it will fail since the constructor of the mbean requires the transaction manager to be already started.

                  Should I start opening bugs for this? Open other forum topics in another more proper channel?

                  I can provide stack traces and more information if needed.

                  It works fine in versions of JBoss AS before 5 because of when the transaction manager starts.

                  • 6. Re: Transaction Demarcation and JBoss AOP 2.0
                    mwringe

                    Stack trace of the error (note test.Test is the mbean that has the aop transaction applied to it)

                    Caused by: java.lang.RuntimeException: Unable to locate the transaction manager
                     at org.jboss.tm.TransactionManagerLocator.locate(TransactionManagerLocator.java:134)
                     at org.jboss.tm.TransactionManagerLocator.locate(TransactionManagerLocator.java:113)
                     at org.jboss.aspects.tx.TxInterceptorFactory.initialize(TxInterceptorFactory.java:57)
                     at org.jboss.aspects.tx.TxInterceptorFactory.createPerJoinpoint(TxInterceptorFactory.java:123)
                     at org.jboss.aop.advice.AspectFactoryDelegator.createPerJoinpoint(AspectFactoryDelegator.java:119)
                     at org.jboss.aop.GeneratedClassAdvisor.addPerClassJoinpointAspect(GeneratedClassAdvisor.java:912)
                     at org.jboss.aop.advice.GeneratedAdvisorInterceptor.<init>(GeneratedAdvisorInterceptor.java:126)
                     at org.jboss.aop.GeneratedClassAdvisor.pointcutResolved(GeneratedClassAdvisor.java:837)
                     at org.jboss.aop.MethodMatchInfo.applyBinding(MethodMatchInfo.java:152)
                     at org.jboss.aop.MethodMatchInfo.overridePopulateBindings(MethodMatchInfo.java:143)
                     at org.jboss.aop.MethodMatchInfo.populateBindings(MethodMatchInfo.java:92)
                     at org.jboss.aop.GeneratedClassAdvisor.fullWorkFinalizeMethodChain(GeneratedClassAdvisor.java:627)
                     at org.jboss.aop.GeneratedClassAdvisor.finalizeMethodChain(GeneratedClassAdvisor.java:596)
                     at org.jboss.aop.GeneratedClassAdvisor.finalizeChains(GeneratedClassAdvisor.java:577)
                     at org.jboss.aop.ClassAdvisor.createInterceptorChains(ClassAdvisor.java:607)
                     at org.jboss.aop.GeneratedClassAdvisor.access$201(GeneratedClassAdvisor.java:65)
                     at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.createInterceptorChains(GeneratedClassAdvisor.java:1303)
                     at org.jboss.aop.GeneratedClassAdvisor.createInterceptorChains(GeneratedClassAdvisor.java:407)
                     at org.jboss.aop.ClassAdvisor$1.run(ClassAdvisor.java:304)
                     at java.security.AccessController.doPrivileged(Native Method)
                     at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:274)
                     at org.jboss.aop.AspectManager.initialiseClassAdvisor(AspectManager.java:731)
                     at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.initialise(GeneratedClassAdvisor.java:1291)
                     at org.jboss.aop.GeneratedClassAdvisor.initialise(GeneratedClassAdvisor.java:143)
                     at test.Test$TestAdvisor.initialise(Test$TestAdvisor.java)
                     at test.Test$TestAdvisor.<init>(Test$TestAdvisor.java)
                     at test.Test.<clinit>(Test.java)
                     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                     at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
                     at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:1242)
                     at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:286)
                     at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:344)
                     at org.jboss.system.ServiceCreator.installPlainMBean(ServiceCreator.java:197)
                     at org.jboss.system.ServiceCreator.install(ServiceCreator.java:115)