7 Replies Latest reply on Nov 26, 2008 8:10 AM by alesj

    JBoss AS5 and TransactionManager Start Order

    mwringe

      I am using the latest jboss as5 from svn head, and I am having an issue with not being able to access the Transaction Manager when a sar is in the deploy directory when the server starts. If the server is already started and the sar is placed in the deploy directory then it deploys properly.

      When the sar is placed in the deploy directory and then the server starts:

      2008-11-20 13:25:18,473 DEBUG [org.jboss.tm.TransactionManagerLocator] (main) Unable to lookup: java:/TransactionManager
      javax.naming.NameNotFoundException: TransactionManager not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       ...
      


      I have tried adding a dependency on the transaction manger for the mbean which causes this issue, but I am using aop to handle the transactions and its requires the transaction manager before checking the dependencies.

      Is there a way to force the sar to be deployed after the transaction manager is already started?

      This looks like it might be related to https://jira.jboss.org/jira/browse/JBAS-6028

        • 1. Re: JBoss AS5 and TransactionManager Start Order
          alesj

          Simple:
          You can either re-order top deployments
          so that deployment containing TM gets fully deployed before your app deployment.
          Problem: not really bullet proof, since, can you really be sure users will not want their own order.
          Depending how hard it is to make this deterministic.

          Harder:
          Programmatically add a dependency on TM for the whole deployment.
          e.g. adding some deployer that only recognizes your deployment and adds explicit dependency on TM for deployment unit
          Problem: do you know how to implement this? ;-)

          Not to worry.
          I'll provide you with the Hard:Problem solution,
          you just give me exact requirements.
          1) How do I recognize your deployment?
          e.g.I know it's a Seam deployment since it has one
          of the following files in its META-INF: seam.properties, components.xml, ...

          • 2. Re: JBoss AS5 and TransactionManager Start Order
            mwringe

             


            Harder:
            Programmatically add a dependency on TM for the whole deployment.
            e.g. adding some deployer that only recognizes your deployment and adds explicit dependency on TM for deployment unit
            Problem: do you know how to implement this? ;-)


            Yeah, that shouldn't be much of a problem (I am writing up a custom deployer for it anyways).

            The bigger issue is that it will affect every sar that uses aop transaction on a class that is also specified as an mbean in the jboss-service.xml file (see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=145746 for more information).

            My question on this thread has been was how to get around the transaction manager startup sequence (while waiting for a reply on the other thread about the aop transaction demarcation issues). And I guess the answer to this is to write a custom deployer.

            • 3. Re: JBoss AS5 and TransactionManager Start Order
              alesj

               

              "mwringe" wrote:

              The bigger issue is that it will affect every sar that uses aop transaction on a class that is also specified as an mbean in the jboss-service.xml file (see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=145746 for more information).

              The you should make this generic. ;-)
              As I don't see how else, w/o explicit TM dependency you're gonna handle that aop transactions.

              btw: what triggers TM lookup before service is configured?

              "mwringe" wrote:

              My question on this thread has been was how to get around the transaction manager startup sequence (while waiting for a reply on the other thread about the aop transaction demarcation issues). And I guess the answer to this is to write a custom deployer.

              I don't understand this.

              Or I don't see the issue.
              e.g.
              1st thread is deploying jbossas deploy directory
              2nd thread comes in, but until TM is installed, our app won't be seen/installed
              The service should be a subject to transaction/2nd-thread usage until it's installed.

              • 4. Re: JBoss AS5 and TransactionManager Start Order
                mwringe

                 

                "alesj" wrote:

                "mwringe" wrote:

                The bigger issue is that it will affect every sar that uses aop transaction on a class that is also specified as an mbean in the jboss-service.xml file (see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=145746 for more information).

                The you should make this generic. ;-)
                As I don't see how else, w/o explicit TM dependency you're gonna handle that aop transactions.

                well I would explicitly add TM as a dependency if it was possible.


                btw: what triggers TM lookup before service is configured?


                AOP manipulates the byte code of the class, one of the things it does is to manipulate the constructor so that the first thing it has is a reference to the transaction manager (if the class is specified to want aop transaction demarcation). Mbeans specified in jboss-service.xml are always created before looking at the dependencies.

                So if an mbean uses aop transactions, its constructor is called before looking at the dependencies and it crashes because it can't find the transaction manager.

                Since this happens in the autogenerated aop manipulations, and this happens before looking at the dependencies specified in the jboss-service.xml, there is nothing that the user can really do about it. [Except create a custom deployer that hacks around the issue (btw, is there a good reference deployer that already does something like this, or am I going to have to create a dummy mbean that requires the TM and have that deployed before the sar)]

                "alesj" wrote:

                "mwringe" wrote:

                My question on this thread has been was how to get around the transaction manager startup sequence (while waiting for a reply on the other thread about the aop transaction demarcation issues). And I guess the answer to this is to write a custom deployer.

                I don't understand this.

                all I was trying to say was that I created this forum thread to figure out how to get the transaction manager to start when I want it too, which the answer I got was to create a custom deployer. My other forum thread was more about how the aop transaction demarcation working properly with the latest AS5

                • 5. Re: JBoss AS5 and TransactionManager Start Order
                  alesj

                   

                  "mwringe" wrote:

                  AOP manipulates the byte code of the class, one of the things it does is to manipulate the constructor so that the first thing it has is a reference to the transaction manager (if the class is specified to want aop transaction demarcation). Mbeans specified in jboss-service.xml are always created before looking at the dependencies.

                  So if an mbean uses aop transactions, its constructor is called before looking at the dependencies and it crashes because it can't find the transaction manager.

                  Since this happens in the autogenerated aop manipulations, and this happens before looking at the dependencies specified in the jboss-service.xml, there is nothing that the user can really do about it. [Except create a custom deployer that hacks around the issue

                  This looks like a horrible design,
                  actually by-passing everything MC stands for. ;-)

                  Mbeans specified in jboss-service.xml are always created before looking at the dependencies.

                  So if an mbean uses aop transactions, its constructor is called before looking at the dependencies and it crashes because it can't find the transaction manager.


                  This should definitely be fixed.
                  If user has explicit dependencies defined they should be used.

                  "mwringe" wrote:

                  (btw, is there a good reference deployer that already does something like this, or am I going to have to create a dummy mbean that requires the TM and have that deployed before the sar)]

                  Why would this dummy mbean help? :-)
                  e.g. your mbean --> TM == your mbean --> dummy --> TM, it's still the same problem ;-)

                  That's what I said, Hard:Problem is not trivial to implement,
                  unles you know how VDF (Virtual deployment framework aka our Deployers)
                  works or you read VDF's reference guide.
                  Since ref guide doesn't exist, it's the first thing. :-)

                  But yeah, I'm more then willing to help you if you fight this on your own.
                  Hint1: MC Deployers project tests are good ref point
                  Hint2: Deployment == DeploymentControllerContext -;)


                  • 6. Re: JBoss AS5 and TransactionManager Start Order
                    mwringe

                     

                    "alesj" wrote:

                    This looks like a horrible design,
                    actually by-passing everything MC stands for. ;-)

                    Mbeans specified in jboss-service.xml are always created before looking at the dependencies.

                    So if an mbean uses aop transactions, its constructor is called before looking at the dependencies and it crashes because it can't find the transaction manager.


                    This should definitely be fixed.
                    If user has explicit dependencies defined they should be used.

                    Agreed :)

                    As an additional note, it using pojo's with a jboss-beans.xml file, then you can use 'demands' which will allow you to specify you want that dependency to be started before creating the bean. But demand does not work with jboss-service.xml.

                    • 7. Re: JBoss AS5 and TransactionManager Start Order
                      alesj

                       

                      "mwringe" wrote:

                      As an additional note, it using pojo's with a jboss-beans.xml file, then you can use 'demands' which will allow you to specify you want that dependency to be started before creating the bean. But demand does not work with jboss-service.xml.

                      You can now use this:
                      - http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4192453#4192453