Version 16

    Q1 How do I get hold of the Kernel object a bean is associated with?

    A1: You can either have the bean implement the org.jboss.kernel.spi.dependency.KernelControllerContextAware interface from which you can

    do getKernel() on the KernelControllerContext passed into the setKernelControllerContext callback.


    Alternatively, you can inject the kernel via a property:

    <property name="kernel"><inject bean="jboss.kernel:service=Kernel"></inject></property>


    Q2 How do I inject a pojo into a legacy mbean?

    A2: The -service.xml deployer in jboss5 allows for injecting kernel pojos:

    <mbean name="...">
       <attribute name="Link"><inject bean="Something" property="whatever" state="Instantiated"></inject>

    Q3 How can a pojo depend on a legacy mbean?

    A3: The jmx name of the mbean can be used in the pojo beans depends declaration:

    <bean name="somepojo" ...>


    Q4 How can a legacy mbean depend on a pojo?

    A4: The name of the pojo bean can be used in the legacy mbean's depends declaration:

    <mbean ...


    Q5 My mbean depends on a pojo bean. In the jmx-console I see the pojo bean service is started, but my service never starts.

    A5: Make sure your mbean depends on the pojo bean itself, not on its JMX proxy. For example:

    <bean name="HAPartition"
      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=DefaultPartition" ...</annotation>

    Won't work:

    <mbean ...


    <mbean ...
       <!-- Depend on the pojo bean, not its JMX proxy -->


    Q6 How do I convert an -service.xml to a -beans.xml?

    A6 See: ConvertingMBeanServiceToMCBean


    Q7 How do I prevent injection until a dependency is fully installed?

    A7 By adding a demand with a state=Configured attribute:

    <bean name="HAJNDI"  class="org.jboss.ha.jndi.HANamingService">
      <property name="distributedTreeManager">
       <bean class="org.jboss.ha.jndi.impl.jbc.JBossCacheDistributedTreeManager">
          <property name="clusteredCache"><inject bean="HAPartitionCacheHandler" property="cache"/></property>
          <demand state="Configured">HAPartition</demand>



    This indicates that the HAJNDI bean should not be brought to its Configured state (when injection occurs) until the HAPartition bean has reached its Installed state.


    Q8 What is the difference between depends and demand elements?

    A8: depend is a dependencyItem on the referenced bean reaching its Start state before the dependee will be allowed to reach its Start state.

    Demand is a dependencyItem on the referenced bean reaching its Installed state before the dependee will be allowed to reach its whenRequired(state attribute of demand) state.


    Q9 How does an mbean depend on an attribute of another mbean?

    A9: In JBossAS 5.0.0.GA, the depends element now supports an 'attribute' attribute that specifies the attribute to inject as the value of the attribute named by optional-attribute-name. For example:


       <!-- A custom deployment of the JBoss JNDI naming service -->
       <mbean code="org.jnp.server.Main"
          <!-- The bootstrap port used to lookup the Naming proxy -->
          <attribute name="Port">10999</attribute>
          <!-- Don't override the default naming service -->
          <attribute name="InstallGlobalService">false</attribute>
          <attribute name="Naming"><inject bean="LocalNamingBean"/></attribute>
          <!-- The detached pooled invoker proxy -->
          <depends optional-attribute-name="NamingProxy"

    indicates that the Proxy attribute of the 'jboss.test:service=proxyFactory,type=pooled,target=Naming' mbean will be injected as the value of the NamingProxy attribute of the 'jboss.test:service=Naming,test=pooled-main' mbean.


    Q10 How do I customize how supply and demand matching works?

    A10: See the following article on supply and demand matching customization.


    Q11 How do I use jboss-classloading.xml in EAR/WAR applications?

    A11: See the case study of how to deploy a WAR within an EAR using JBoss5 classloading domains here



    Referenced by: