6 Replies Latest reply on Jun 1, 2005 5:01 AM by dimitris

    my dependency doesn't work

    tom.baeyens

      i checked the faq's, dtd, google and took a jboss advanced training but couldn't find an answer. maybe i overlooked something and fell asleep at the wrong training module...

      i want to make the hypersonic database available for tcp connections like this:

      (deploy/hsqldb-ds.xml)

      <datasources>
      
       <!-- hypersonic database -->
       <mbean code="org.jboss.jdbc.HypersonicDatabase"
       name="jboss:service=Hypersonic">
       <attribute name="Port">1701</attribute>
       <attribute name="Silent">true</attribute>
       <attribute name="Database">default</attribute>
       <attribute name="Trace">false</attribute>
       <attribute name="No_system_exit">true</attribute>
       </mbean>
      
       <!-- datasource on top of the hypersonic database -->
       <local-tx-datasource>
       <jndi-name>DefaultDS</jndi-name>
       <connection-url>jdbc:hsqldb:hsql://localhost:1701</connection-url>
       <driver-class>org.hsqldb.jdbcDriver</driver-class>
       <user-name>sa</user-name>
       <password></password>
       <min-pool-size>5</min-pool-size>
       <max-pool-size>20</max-pool-size>
       <idle-timeout-minutes>0</idle-timeout-minutes>
       <track-statements/>
       <security-domain>HsqlDbRealm</security-domain>
       <metadata><type-mapping>Hypersonic SQL</type-mapping></metadata>
       <depends>jboss:service=Hypersonic</depends>
       </local-tx-datasource>
      
      </datasources>


      then i want to define a dependency from my new jbpm MBean service on the datasource like this:

      (deploy/jbpm.sar/META-INF/jboss-server.xml)
      <server>
       <mbean code="org.jbpm.jmx.JbpmService"
       name="jboss.jbpm:name=DefaultJbpm,service=JbpmService"
       description="Default jBPM Service">
       <depends>jboss.jca:name=DefaultDS,service=LocalTxCM</depends>
       <attribute name="JndiName">java:/jbpm/JbpmSessionFactory</attribute>
       </mbean>
      </server>


      still my service is started before the datasource is bound to JNDI.

      [exec] 15:57:16,484 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
       [exec] --- MBeans waiting for other MBeans ---
       [exec] ObjectName: jboss.jbpm:name=DefaultJbpm,service=JbpmService
       [exec] State: FAILED
       [exec] Reason: org.hibernate.HibernateException: Could not find datasource
       [exec] I Depend On:
       [exec] jboss.jca:name=DefaultDS,service=LocalTxCM
       [exec] --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
       [exec] ObjectName: jboss.jbpm:name=DefaultJbpm,service=JbpmService
       [exec] State: FAILED
       [exec] Reason: org.hibernate.HibernateException: Could not find datasource
       [exec] I Depend On:
       [exec] jboss.jca:name=DefaultDS,service=LocalTxCM
       [exec] 15:57:16,750 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080


      any pointer is appreciated.

      i tried to learn about the optional-attribute-name attribute of the depends element from the dtd, but don't get it yet. is that my problem ? if yes, is there another description somewhere ?

      regards, tom.

        • 1. Re: my dependency doesn't work
          dimitris

          It could be you need to move your initialization logic from createService() to startService().

          • 2. Re: my dependency doesn't work
            dimitris

            And better to depend on

            jboss.jca:service=DataSourceBinding,name=DefaultDS.

            • 3. Re: my dependency doesn't work
              dimitris

              The optional-attribute-name is just a very poor name for something simple:

              The dependency works as usual, and in addition, the value of the dependency (usually the ObjectName of the MBean you depend on, is "injected" to the writeable attribute that you specify in the optional-attribute-name attribute.

              So in your case you could have in your mbean an attribute calls "DataSourceObjectName":

              void setDataSourceObjectName(ObjectName name);
              ObjectName getDataSourceObjectName();

              • 4. Re: my dependency doesn't work
                tom.baeyens

                thanks !
                i'll have a look and let you know here if it works out.

                regards, tom.

                • 5. Re: my dependency doesn't work
                  tom.baeyens

                  i got it to work.

                  but only with startService & stopService in combination with a dependency on jboss.jca:service=DataSourceBinding,name=DefaultDS as you suggested.

                  using createService & destroyService doesn't work.

                  just FMI: how come the service controller only takes dependencies into account for starting and stopping and not for creating and destroying ?

                  regards, tom.

                  • 6. Re: my dependency doesn't work
                    dimitris

                    The ServiceController does take into account create & start dependencies.

                    Dependencies work in 2 steps, like this: Mbean A depends on B means:

                    create(B), create(A),
                    start(B), start(A).

                    It would be of no use to have:

                    create(B), start(B),
                    create(A), start(A)

                    We need this trick to handle chicken and egg problems, like 2 mbeans that use each other. It would be impossible to do that in 1 step.