Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6750391

MBean resource injection could cause MBean registration failure if code miss dependencies

    Details

      Description

      A consequence of the support in JMX 2.0 of Resource injection with the @Resource annotation, the code of an MBean is introspected when registered within the MBeanServer.
      If for some reason you've in the MBean code some import clauses of classes not present at run time, the MBean creation will fail.
      We all agree it's not recommended to miss such classes, it's a customer setup issue.
      But point is the MBean creation was previously doing well (JMX 1.4) so it's a behavior change, there's a risk (a chance ?) to discover with JMX 2.0 a setup issue that was kept silent.

      Failure example:
      java.lang.NoClassDefFoundError: qa/utils/mbeanref/MBeanInfoRef
         at java.lang.Class.getDeclaredMethods0(Native Method)
         at java.lang.Class.privateGetDeclaredMethods(Class.java:2439)
         at java.lang.Class.getDeclaredMethods(Class.java:1805)
         at com.sun.jmx.mbeanserver.MBeanInjector$ClassInjector$1.run(MBeanInjector.java:194)
         at com.sun.jmx.mbeanserver.MBeanInjector$ClassInjector$1.run(MBeanInjector.java:192)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.jmx.mbeanserver.MBeanInjector$ClassInjector.addMembers(MBeanInjector.java:190)
         at com.sun.jmx.mbeanserver.MBeanInjector$ClassInjector.<init>(MBeanInjector.java:95)
         at com.sun.jmx.mbeanserver.MBeanInjector.injectorForClass(MBeanInjector.java:283)
         at com.sun.jmx.mbeanserver.MBeanInjector.access$000(MBeanInjector.java:49)
         at com.sun.jmx.mbeanserver.MBeanInjector$ClassInjector.<init>(MBeanInjector.java:90)
         at com.sun.jmx.mbeanserver.MBeanInjector.injectorForClass(MBeanInjector.java:283)
         at com.sun.jmx.mbeanserver.MBeanInjector.validate(MBeanInjector.java:74)
         at com.sun.jmx.mbeanserver.Introspector.checkCompliance(Introspector.java:156)
         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:305)
         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:212)
         at com.sun.jmx.mbeanserver.JmxMBeanServer.createMBean(JmxMBeanServer.java:427)
         at com.sun.jdmk.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:130)
         at com.sun.jdmk.JdmkMBeanServerImpl.createMBean(JdmkMBeanServerImpl.java:283)
         at com.sun.jdmk.comm.RmiConnectorServerObjectImplV2.createMBean(RmiConnectorServerObjectImplV2.java:113)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:623)
         at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
         at sun.rmi.transport.Transport$1.run(Transport.java:177)
         at sun.rmi.transport.Transport$1.run(Transport.java:174)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
         at java.lang.Thread.run(Thread.java:674)
      Caused by: java.lang.ClassNotFoundException: qa.utils.mbeanref.MBeanInfoRef
         at java.net.URLClassLoader$1.run(URLClassLoader.java:220)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:209)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:208)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:270)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:338)
         ... 35 more

        Attachments

          Activity

            People

            • Assignee:
              sjiang Shanliang Jiang (Inactive)
              Reporter:
              yjoan Yves Joan (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: