2 Replies Latest reply on Aug 14, 2008 9:23 AM by Adrian Brock

    @JMX on a bootstrap service

    Brian Stansberry Master

      I'm trying to apply an @JMX annotation to a bean that's deployed as part of the bootstrap. The bean deploys fine, and I can see it in the jmx-console, but during shutdown I'm getting a CNFE. Any ideas why?

      The deployment:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <deployment xmlns="urn:jboss:bean-deployer:2.0">
      
       <classloader><inject bean="bindings-classloader:0.0.0"/></classloader>
      
       <classloader name="bindings-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
       <root>${jboss.lib.url}/jboss-bindingservice.jar</root>
       </classloader>
      
       <bean name="ServiceBindingManager" class="org.jboss.services.binding.ServiceBindingManager">
      
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.system:service=ServiceBindingManager",exposedInterface=org.jboss.services.binding.ServiceBindingManagerMBean.class,registerDirectly=true)</annotation>
      
       <constructor>
       <!-- The set of bindings to use for this server -->
       <parameter>${jboss.service.binding.set:ports-default}</parameter>


      The shutdown logging:

      2008-08-13 17:09:35,310 DEBUG [org.jboss.system.ServiceController] (JBoss Shutdown Hook) stopping service: jboss.system:service=ServiceBindingManager
      2008-08-13 17:09:35,311 DEBUG [org.jboss.system.ServiceController] (JBoss Shutdown Hook) destroying service: jboss.system:service=ServiceBindingManager
      2008-08-13 17:09:35,311 DEBUG [org.jboss.system.ServiceController] (JBoss Shutdown Hook) removing service: jboss.system:service=ServiceBindingManager
      2008-08-13 17:09:35,311 DEBUG [org.jboss.system.ServiceCreator] (JBoss Shutdown Hook) Removing mbean from server: jboss.system:service=ServiceBindingManager
      2008-08-13 17:09:35,311 DEBUG [org.jboss.system.microcontainer.jmx.ServiceControllerRegistrationLifecycleCallback] (JBoss Shutdown Hook) Unregistered MBean jboss.system:service=ServiceBindingManager
      2008-08-13 17:09:35,519 WARN [org.jboss.kernel.plugins.dependency.PreInstallAction] (JBoss Shutdown Hook) Unexpected error removing metadata:
      java.lang.RuntimeException: Error creating annotation for @org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.system:service=ServiceBindingManager",exposedInterface=org.jboss.services.binding.ServiceBindingManagerMBean.class)
       at org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData.getAnnotationInstance(AbstractAnnotationMetaData.java:123)
       at org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData.getAnnotationInstance(AbstractAnnotationMetaData.java:98)
       at org.jboss.kernel.plugins.dependency.KernelScopeInfo.updateAnnotations(KernelScopeInfo.java:323)
       at org.jboss.kernel.plugins.dependency.KernelScopeInfo.updateClassAnnotations(KernelScopeInfo.java:150)
       at org.jboss.kernel.plugins.dependency.KernelScopeInfo.updateMetaData(KernelScopeInfo.java:122)
       at org.jboss.dependency.plugins.AbstractScopeInfo.removeMetaData(AbstractScopeInfo.java:164)
       at org.jboss.kernel.plugins.metadata.basic.BasicKernelMetaDataRepository.removeMetaData(BasicKernelMetaDataRepository.java:77)
       at org.jboss.kernel.plugins.dependency.PreInstallAction.removeMetaData(PreInstallAction.java:214)
       at org.jboss.kernel.plugins.dependency.PreInstallAction.uninstallActionInternal(PreInstallAction.java:198)
       at org.jboss.kernel.plugins.dependency.InstallsAwareAction.uninstallAction(InstallsAwareAction.java:157)
       at org.jboss.kernel.plugins.dependency.InstallsAwareAction.uninstallAction(InstallsAwareAction.java:42)
       at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleUninstallAction(SimpleControllerContextAction.java:79)
       at org.jboss.dependency.plugins.action.AccessControllerContextAction.uninstall(AccessControllerContextAction.java:131)
       at org.jboss.dependency.plugins.AbstractControllerContextActions.uninstall(AbstractControllerContextActions.java:58)
       at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:354)
       at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:1536)
       at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1201)
       at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1110)
       at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:618)
       at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:534)
       at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBean(AbstractKernelDeployer.java:406)
       at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBeans(AbstractKernelDeployer.java:385)
       at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeploy(AbstractKernelDeployer.java:162)
       at org.jboss.kernel.plugins.deployment.BasicKernelDeployer.undeploy(BasicKernelDeployer.java:88)
       at org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer.undeploy(BasicXMLDeployer.java:95)
       at org.jboss.kernel.plugins.deployment.BasicKernelDeployer.shutdown(BasicKernelDeployer.java:102)
       at org.jboss.bootstrap.microcontainer.ServerImpl.doShutdown(ServerImpl.java:163)
       at org.jboss.bootstrap.AbstractServerImpl.shutdownServer(AbstractServerImpl.java:523)
       at org.jboss.bootstrap.AbstractServerImpl$ShutdownHook.run(AbstractServerImpl.java:827)
      Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.jboss.services.binding.ServiceBindingManagerMBean
       at org.jboss.annotation.factory.AnnotationCreator.visit(AnnotationCreator.java:236)
       at org.jboss.annotation.factory.ast.ASTIdentifier.jjtAccept(ASTIdentifier.java:37)
       at org.jboss.annotation.factory.AnnotationCreator.visit(AnnotationCreator.java:111)
       at org.jboss.annotation.factory.ast.ASTMemberValuePair.jjtAccept(ASTMemberValuePair.java:37)
       at org.jboss.annotation.factory.AnnotationCreator.createAnnotation(AnnotationCreator.java:372)
       at org.jboss.annotation.factory.AnnotationCreator.createAnnotation(AnnotationCreator.java:394)
       at org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData.getAnnotationInstance(AbstractAnnotationMetaData.java:114)
       ... 28 more
      Caused by: java.lang.ClassNotFoundException: org.jboss.services.binding.ServiceBindingManagerMBean
       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:242)
       at org.jboss.annotation.factory.AnnotationCreator.visit(AnnotationCreator.java:170)
       ... 34 more
      2008-08-13 17:09:35,529 DEBUG [org.jboss.classloader.spi.base.BaseClassLoaderDomain] (JBoss Shutdown Hook) ClassLoaderDomain@33b121{DefaultDomain} unregisterClassLoader BaseClassLoader@7b21ea{bindings-classloader:0.0.0$MODULE}
      2008-08-13 17:09:35,529 DEBUG [org.jboss.mx.loading.UnifiedLoaderRepository3] (JBoss Shutdown Hook) UnifiedLoaderRepository removed(false) null
      2008-08-13 17:09:35,529 DEBUG [org.jboss.classloader.spi.base.BaseClassLoaderPolicy] (JBoss Shutdown Hook) VFSClassLoaderPolicy@1efa490{bindings-classloader:0.0.0$MODULE} shutdown!
      2008-08-13 17:09:35,529 DEBUG [org.jboss.classloader.spi.base.BaseClassLoader] (JBoss Shutdown Hook) BaseClassLoader@7b21ea{bindings-classloader:0.0.0$MODULE} shutdown!
      2008-08-13 17:09:35,529 DEBUG [org.jboss.classloading.spi.dependency.Domain] (JBoss Shutdown Hook) org.jboss.classloading.spi.dependency.Domain@b51c29{DefaultDomain} add module VFSClassLoaderPolicyModule bindings-classloader:0.0.0




        • 1. Re: @JMX on a bootstrap service
          Adrian Brock Master

          It's a bug: https://jira.jboss.org/jira/browse/JBMICROCONT-339
          actually there's more than one in there. :-(

          • 2. Re: @JMX on a bootstrap service
            Adrian Brock Master

            I've fixed this and also removed the potential memory leak
            by adding a CachingAnnotationMetaData interface.

            It's not as optimal as I would like because of the property annotations.
            In that case the annotation gets added to both the getter and setter,
            so when we remove the annoation for the getter we loose track of the
            annotation when we want to remove the setter, so we have to reconstruct it.

            If this was a way to optimize that case, the code in KernelScopeInfo could be

             Annotation annotationInstance = null;
             if (annotation instanceof CachingAnnotationMetaData)
             annotationInstance = ((CachingAnnotationMetaData) annotation).removeAnnotation();
            - if (annotationInstance == null)
            + else
             annotationInstance = annotation.getAnnotationInstance(classloader);
             // Null means we never constructed it in the first place
             if (annotationInstance != null)
             mutable.removeAnnotation(annotationInstance.annotationType());