5 Replies Latest reply on Mar 3, 2009 3:59 PM by dallen6

    JBossTransactionServices and WebBeans

    alesj

      Moving this to forum.

      "david.allen" wrote:

      how to best inject the RealTransactionManager bean into one of our
      beans.

      I modified webbeans-ejb-jboss-beans.xml to also have the following bean
      declaration:
       <beanfactory name="JBossTransactionServices"
      class="org.jboss.webbeans.integration.ejb.JBossTransactionServices">
       <property name="controller"><inject
      bean="jboss.kernel:service=KernelController" /></property>
       <property name="transactionManager"><inject
      bean="RealTransactionManager" /></property>
       </beanfactory>
      


      That class/bean just needs the javax.transaction.TransactionManager that
      the AS is using.

      However, since this is a deployer perhaps, the TM is not ready or
      loaded? I get the following error:

      DEPLOYMENTS MISSING DEPENDENCIES:
      Deployment "JBossTransactionServices" is missing the following
      dependencies:
      Dependency "RealTransactionManager" (should be in state
      "Configured", but is actually in state "** NOT FOUND Depends on
      'RealTransactionManager' **")


      I also tried adding a jboss-dependency.xml, but I really do not know
      what name to use for the <item> element, or for that matter any of the
      attributes. Is this the correct approach? Do you know the exact values
      to put into jboss-dependency.xml elements for this case?


        • 1. Re: JBossTransactionServices and WebBeans
          alesj

           

          "david.allen" wrote:

          how to best inject the RealTransactionManager bean into one of our
          beans.

          I modified webbeans-ejb-jboss-beans.xml to also have the following bean
          declaration:
           <beanfactory name="JBossTransactionServices"
          class="org.jboss.webbeans.integration.ejb.JBossTransactionServices">
           <property name="controller"><inject
          bean="jboss.kernel:service=KernelController" /></property>
           <property name="transactionManager"><inject
          bean="RealTransactionManager" /></property>
           </beanfactory>
          


          That class/bean just needs the javax.transaction.TransactionManager that
          the AS is using.

          Add option="callback" attribute to TM's inject.
          This will inject your TM once it's available.

          "david.allen" wrote:

          However, since this is a deployer perhaps, the TM is not ready or
          loaded? I get the following error:

          DEPLOYMENTS MISSING DEPENDENCIES:
          Deployment "JBossTransactionServices" is missing the following
          dependencies:
          Dependency "RealTransactionManager" (should be in state
          "Configured", but is actually in state "** NOT FOUND Depends on
          'RealTransactionManager' **")

          Yes, the TM is not there yet.
          But we do call the checkComplete, which causes this error msg.

          We do boot, deployers and deploy in separate steps,
          invoking MainDeployer::checkComplete after each of them.
          Hence the deployers don't yet see the deploy, which is where the TM is deployed.

          "david.allen" wrote:

          I also tried adding a jboss-dependency.xml, but I really do not know
          what name to use for the <item> element, or for that matter any of the
          attributes. Is this the correct approach?

          This wouldn't help either, as what you would actually do is
          create a dependency for a whole deployment on a particular bean,
          where previously you had a single bean depending on that bean.
          The error would be almost the same.

          "david.allen" wrote:

          Do you know the exact values
          to put into jboss-dependency.xml elements for this case?

          Sure, I wrote the jboss-dependency.xml mechanism. :-)

          Check its test cases or read more about it here:
          - http://www.jboss.org/community/docs/DOC-13178

          • 2. Re: JBossTransactionServices and WebBeans
            alesj

             

            "alesj" wrote:
            "david.allen" wrote:

            how to best inject the RealTransactionManager bean into one of our
            beans.

            I modified webbeans-ejb-jboss-beans.xml to also have the following bean
            declaration:
             <beanfactory name="JBossTransactionServices"
            class="org.jboss.webbeans.integration.ejb.JBossTransactionServices">
             <property name="controller"><inject
            bean="jboss.kernel:service=KernelController" /></property>
             <property name="transactionManager"><inject
            bean="RealTransactionManager" /></property>
             </beanfactory>
            


            That class/bean just needs the javax.transaction.TransactionManager that
            the AS is using.

            Add option="callback" attribute to TM's inject.
            This will inject your TM once it's available.

            Unfortunately this won't work with bean factory.
            But do you really need bean factory, or is plain bean enough?


            • 3. Re: JBossTransactionServices and WebBeans
              dallen6

              I doubt that beanFactory is really needed in this case, but I was following the same pattern as all the other bean factories in that deployer. Ideally, there should just be one bean. The MC integration code is using Java code instead of injection with bean files, so I really do not understand any of it well enough to deviate from the samples already there.

              In any event, the error is gone. I still need to check to see if it really injected anything.

              • 4. Re: JBossTransactionServices and WebBeans
                dallen6

                The injection does work with option="callback". Maybe it is OK in this case because it is not being used until some later deployment from deploy is actually used after the entire server is started.

                • 5. Re: JBossTransactionServices and WebBeans
                  dallen6

                  The bean factory was replaced with just the bean. The Java code for the deployer needed to be changed to not define a factory and factory method for this bean via the MC beans SPI.