9 Replies Latest reply on Oct 29, 2007 7:55 AM by alesj

    MicroContainer with external dependencies

    ataylor

      I have a dependency on a datasource being bound to a naming server. This is fine when i run bootstrap as i control when and how it is created. However when i run within the JBoss AS the datasource is not bound until after the microcontainer has started. Is there any way of defining a dependency on this datasource. If i was running as a service i would add the following to my bean definition

      <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>


        • 1. Re: MicroContainer with external dependencies
          alesj

           

          "ataylor" wrote:
          If i was running as a service i would add the following to my bean definition
          <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>

          You mean mbean?

          As MC being full state machine, this is of course there:
           <bean name="PojoInjectee" class="org.jboss.example.microcontainer.mbeans.PojoInjectee">
           <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
           </bean>
          
           <bean name="demander" class="org.jboss.example.microcontainer.demand.Demander">
           <demand state="Create">jboss.jca:service=DataSourceBinding,name=DefaultDS</demand>
           </bean>
          

          Even with additional 'demand' dependency. ;-)

          But then your datasource should also be registered through MC.
          Or see Carlo's JNDI problem: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079099#4079099

          • 2. Re: MicroContainer with external dependencies
            ataylor

            ok, that worked cheers.

            If i register my datasource within the MC something like

            <bean name="DataSource" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
             <property name="driverClass">com.mysql.jdbc.Driver</property>
             <property name="connectionURL">jdbc:mysql://localhost:3306/messaging</property>
             <property name="userName">sa</property>
            </bean>
            



            And another app within the JBoss AS also connects to this database, via the DefaultDS, wont I be using a different connection pool?

            • 3. Re: MicroContainer with external dependencies
              alesj

               

              "ataylor" wrote:

              And another app within the JBoss AS also connects to this database, via the DefaultDS, wont I be using a different connection pool?

              This is out-of-the-scope of MC. ;-)

              All MC will do is instantiate new LTDS bean, fill it in with provided propertys, call create/start methods and finally install the bean into registry.

              Check the code for how LTDS works, or how can it be tuned to use existing cpool.


              • 4. Re: MicroContainer with external dependencies
                ataylor

                If have the following definition

                <bean name="ServiceLocator" class="org.jboss.jms.server.microcontainer.ServiceLocator">
                 <depends>jboss:service=TransactionManager</depends>
                 <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
                 </bean>
                


                i get the error
                jboss.jca:service=DataSourceBinding,name=DefaultDS -> ** NOT FOUND **


                The dependency on the Transaction Manager is enforced correctly, however it cant seem to find the datasource binding. Is this to do with the fact that these are deployed slightly differently in the App Server. i.e. the datasource mbean is dynamically created from the *-ds.xml file at startup time?

                Is the MC not able to enforce this?

                • 5. Re: MicroContainer with external dependencies
                  alesj

                  Can you check the JMX console for datasource mbean?

                  What about if you change order of props --> jboss.jca:name=DefaultDS,service=DataSourceBinding?
                  This should not matter - we fixed it - but just to see where the problem might be.

                  MC definitely knows how to enforce this kind of dependices. ;-)

                  • 6. Re: MicroContainer with external dependencies
                    ataylor

                    cheers Ales, that did the trick.
                    many thanks.

                    • 7. Re: MicroContainer with external dependencies
                      alesj

                       

                      "ataylor" wrote:
                      cheers Ales, that did the trick.
                      many thanks.

                      Great that it worked.

                      But it shouldn't depend on the ObjectName props order.
                      Either you have some old version that doesn't have the fixes that we did for this, or we missed some case. :-)

                      What's your version again?
                      Or the whole env?

                      • 8. Re: MicroContainer with external dependencies
                        ataylor

                        i'm running in JBoss 5.0.0.Beta2

                        • 9. Re: MicroContainer with external dependencies
                          alesj

                          Can you try the latest JBoss AS5 trunk?