1 Reply Latest reply on May 18, 2007 9:57 AM by Serg Prasolov

    @Depends injection after redeploy

    Serg Prasolov Newbie


      jdk5, jboss-4.2.0.CR2

      Something strange in @Depends injection happens. I have two JMX deployed in _two_ different ears.

      @Service(objectName = "A")
      public class ABean implements A {
       private B b = null;
      @Service(objectName = "B")
      public class BBean implements B {

      When deployed firstly, everything is fine. Then I undeploy b.ear and depoly it again. I can see A.stop() executed on undeploy, but after b.ear is deployed again, no injection into A is done. (Looking into jndi for a value strangely fails too, but I think this is not correct to replace injection manually.) So, I need to redeploy all dependant ears to get proper injection done.

      Is it a correct behavior?

      I looked into source code, there is a org.jboss.ejb3.service.ServiceContainer class, where in rows 141-166 there is a method, which is called when B deployment happens:

      public void start() throws Exception {
       try {
      (*) injectDependencies(beanContext);
      (**) registerManagementInterface();
       } catch (Exception e) {

      In (*) does its work, but it uses ServiceContainer.beanContext.bean as a target for injection, while (**) calls start() for another instance of my JMX A, which is in ServiceContainer.singleton field.

      I noticed that when we deploy an mx bean everything ok, ServiceContainer.singleton is used when ServiceContainer.beanContext is being inited, so ServiceContainer.singleton == ServiceContainer.beanContext.bean afterwards. But when we redeploy something our mx bean depends on, there is a call of ServiceController.create() for all dependant mx beans (they should apparently be stopped until then), and at that time ServiceContainer.singleton != ServiceContainer.beanContext.bean, which causes the problem.

      I am not an expert in JBoss, of cause my investigations and ideas can easily be incorrect. Please, help me understand why I need to restart the whole server if I only redeploy an ear...