2 Replies Latest reply on Feb 13, 2009 9:02 AM by adrian.brock

    Duplicate DeploymentContext registration

    alesj

      I thought I had this one:
      - http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4209160#4209160
      But now I'm sure I got it wrong. :-)

      I did a small test, with having -beans.xml as a sub-sub-deployment,
      and it fails as expected. ;-(

      * test.jar
      ** META-INF
      ** inner.jar
      *** META-INF
      *** my-beans.xml

      It's the recursion in AbstractDeploymentContext that gets called twice.
      It will always fail for any sub^n-deployment, where n > 1.

        • 1. Re: Duplicate DeploymentContext registration
          alesj

          This eliminates the duplicates:

          Index: deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java
          ===================================================================
          --- deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java (revision 83617)
          +++ deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java (working copy)
          @@ -993,12 +993,15 @@
           log.warn("Unable to register deployment mbean " + context.getName(), e);
           }
           }
          - List<DeploymentContext> children = context.getChildren();
          - for (DeploymentContext child : children)
          - registerMBeans(child, true);
          - List<DeploymentContext> components = context.getComponents();
          - for (DeploymentContext component : components)
          - registerMBeans(component, false);
          + if (this == context || registerContext == false)
          + {
          + List<DeploymentContext> children = context.getChildren();
          + for (DeploymentContext child : children)
          + registerMBeans(child, true);
          + List<DeploymentContext> components = context.getComponents();
          + for (DeploymentContext component : components)
          + registerMBeans(component, false);
          + }
           }
          
           /**
          @@ -1021,12 +1024,15 @@
           log.trace("Unable to unregister deployment mbean " + context.getName(), e);
           }
           }
          - List<DeploymentContext> children = context.getChildren();
          - for (DeploymentContext child : children)
          - unregisterMBeans(child, true);
          - List<DeploymentContext> components = context.getComponents();
          - for (DeploymentContext component : components)
          - unregisterMBeans(component, false);
          + if (this == context || unregisterContext == false)
          + {
          + List<DeploymentContext> children = context.getChildren();
          + for (DeploymentContext child : children)
          + unregisterMBeans(child, true);
          + List<DeploymentContext> components = context.getComponents();
          + for (DeploymentContext component : components)
          + unregisterMBeans(component, false);
          + }
           }
          


          And another issue.
          Isn't DeployersImpl::registerMBean called too early?
          As at that point we don't have any components yet,
          since the deployment hasn't gone yet through deployment stages.
          It's just installed + manual mode --> Not_Installed state.


          • 2. Re: Duplicate DeploymentContext registration

             

            "alesj" wrote:
            This eliminates the duplicates:


            I found it very difficult to understand what the problem was from the forum threads
            other than it produced a spurious warning, but I used your deployment structure to create a test that reproduced it and fixed the problem.

            https://jira.jboss.org/jira/browse/JBDEPLOY-158

            The issue was that both registerMBeans() from the top level deployment
            and registerMBeans() from the subdeployment were trying to install the
            sub-subdeployment mbean.

            I've fixed it such that each mbean only recurses to one-level which is I think
            what your fix was trying to do, but it wasn't very clean.


            And another issue.
            Isn't DeployersImpl::registerMBean called too early?
            As at that point we don't have any components yet,
            since the deployment hasn't gone yet through deployment stages.
            It's just installed + manual mode --> Not_Installed state.


            The idea is that the mbean is deployed as early as possible so you can analyse it
            using JMX.
            If you add/remove components or subdeployments later there are hooks to (un)register the mbeans.

            I also started some much need missing tests to make sure this doesn't regress.