2 Replies Latest reply on Jan 24, 2003 12:01 AM by coyotesqrl

    MBean instantiation and NoClassDefFoundErrors


      This morning, my colleague began getting NoClassDefFoundErrors on instantiation of an MBean. We belive we tracked it down to a timing issue with jar deployment. Let me describe our setup and then what I *believe* to be the problem.

      We have a directory named oware.sar under the deploy directory. Within that directory we have the usual META-INF/jboss-service.xml, several jars, and classes under a hierarchy (oware.sar/com/...).

      Several of our mbeans - with classes found in that com tree - reference files in one of the jars in the sar.

      I believe that the MBeans are being instantiated before that jar has been deployed. This snippet of a comment from org.jboss.system.ServiceController leads me to believe this: "deploy doesn't bother with service lifecycle only MBean instanciation/registration/configuration"

      1. Can my assumption be correct that the MBean is getting instantiated before all the jars in the sar directory have been deployed?

      2. Is there a way to prevent my MBeans from being instantiated until after deployment is finished? We tried depending on ServiceDeployer, but that didn't help. Our guess is that the ServiceDeployer is indeed started, but just hasn't finished.

      3. Is it correct that MBean instantiation pays no attention to dependency ordering? Why do the MBeans need to get instantiated before it's time for them to start?

      Richard Porter

        • 1. Re: MBean instantiation and NoClassDefFoundErrors

          The deployment is done using the following steps.

          1) Classloaders are created
          2) MBeans are instantiated and registered with the
          3) create()/createService()
          4) start()/startService()

          Sounds like your problem is with step 1
          Why can't the MBeanServer in step 2 see your classes that
          should have been deployed in step 1?

          Can you jar -tf the deployment and any subdeployments?
          You can filter irrelevent bits to keep it small.


          • 2. Re: MBean instantiation and NoClassDefFoundErrors

            We're not exactly sure what the problem was. By rebuilding the jar containing the classes that were not being found by the loader, we were able to stop the problem from happening. I'd guess there was something wrong with that jar, but we queried the ServerInfo MBean after the server was up and saw that the class was deployed.

            Very strange.

            Thanks for the advice; if we see it again, we're probably just going to explode the offending jar into the directory structure. This is really just an issue for a few of us doing infrastructure development. In the end, most will only have jars.

            -Richard Porter