• 4.0.2.3

      Starting up with the Metrics plugin installed and Java 10 shows the following stack trace (Jenkins still starts though):

       

      Jun 18, 2018 5:03:23 PM hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1 error
      WARNING: Failed to instantiate Key[type=jenkins.metrics.impl.VMMetricProviderImpl, annotation=[none]]; skipping this component
      com.google.inject.ProvisionException: Unable to provision, see the following errors:

      1) Error injecting constructor, java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getProcessCpuTime() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @1ae408df
      at jenkins.metrics.impl.VMMetricProviderImpl.<init>(VMMetricProviderImpl.java:61)

      1 error
      at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:52)
      at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
      at hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1.get(ExtensionFinder.java:432)
      at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
      at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
      at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
      at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
      at hudson.ExtensionFinder$GuiceFinder._find(ExtensionFinder.java:394)
      at hudson.ExtensionFinder$GuiceFinder.find(ExtensionFinder.java:385)
      at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:493)
      at hudson.ExtensionList.load(ExtensionList.java:380)
      at hudson.ExtensionList.ensureLoaded(ExtensionList.java:318)
      at hudson.ExtensionList.iterator(ExtensionList.java:172)
      at jenkins.metrics.api.Metrics.afterExtensionsAugmented(Metrics.java:338)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
      at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
      at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
      at jenkins.model.Jenkins$5.runTask(Jenkins.java:1068)
      at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
      at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
      at java.base/java.lang.Thread.run(Thread.java:844)
      Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getProcessCpuTime() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @1ae408df
      at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337)
      at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281)
      at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
      at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
      at jenkins.metrics.impl.VMMetricProviderImpl$CpuUsageGauge.<init>(VMMetricProviderImpl.java:226)
      at jenkins.metrics.impl.VMMetricProviderImpl.<init>(VMMetricProviderImpl.java:71)
      at jenkins.metrics.impl.VMMetricProviderImpl$$FastClassByGuice$$bd4f8b03.newInstance(<generated>)
      at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
      at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
      at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
      at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
      at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
      at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
      at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
      at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
      ... 26 more

          [JENKINS-52017] Metrics Plugin relies on un-exposed module API

          Sam Van Oort added a comment - - edited

          Workaround, per this blog:

          https://blog.codefx.org/java/five-command-line-options-to-hack-the-java-9-module-system/#Accessing-Internal-APIs-With--add-exports

          Add the following to the Java options:

          --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED

          We could probably make this more specific to just the classes needed, of course (and just the plugin module once it has one).

          Sam Van Oort added a comment - - edited Workaround, per this blog: https://blog.codefx.org/java/five-command-line-options-to-hack-the-java-9-module-system/#Accessing-Internal-APIs-With--add-exports Add the following to the Java options: --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED We could probably make this more specific to just the classes needed, of course (and just the plugin module once it has one).

          was this resolved by JENKINS-52061?

          Stephen Connolly added a comment - was this resolved by JENKINS-52061 ?

          Baptiste Mathus added a comment - - edited

          Pretty sure this is actually unresolved, caused by https://github.com/jenkinsci/metrics-plugin/blob/d9b0eb3c576dd1aeff3bff113ca9cd0253aef40f/src/main/java/jenkins/metrics/impl/VMMetricProviderImpl.java#L226. Will double-check and possibly reopen soonish

          I confirm that it does not stop Jenkins from starting though.

          Just seen with Jenkins 2.153-SNAPSHOT on Java 11:

          nov. 29, 2018 10:59:35 PM hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1 errorWARNING: Failed to instantiate Key[type=jenkins.metrics.impl.VMMetricProviderImpl, annotation=[none]]; skipping this component
          com.google.inject.ProvisionException: Unable to provision, see the following errors:
          
          1) Error injecting constructor, java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getProcessCpuTime() accessible: module jdk.management does not "opens com.sun.manage
          ment.internal" to unnamed module @41b1dccd
            at jenkins.metrics.impl.VMMetricProviderImpl.<init>(VMMetricProviderImpl.java:61)
          
          1 error
                  at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:52)
                  at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
                  at hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1.get(ExtensionFinder.java:440)        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
                  at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
                  at hudson.ExtensionFinder$GuiceFinder._find(ExtensionFinder.java:402)
                  at hudson.ExtensionFinder$GuiceFinder.find(ExtensionFinder.java:393)
                  at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:494)
                  at hudson.ExtensionList.load(ExtensionList.java:380)
                  at hudson.ExtensionList.ensureLoaded(ExtensionList.java:318)
                  at hudson.ExtensionList.iterator(ExtensionList.java:172)
                  at jenkins.metrics.api.Metrics.afterExtensionsAugmented(Metrics.java:335)
                  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
                  at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
                  at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
                  at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
                  at jenkins.model.Jenkins$5.runTask(Jenkins.java:1069)
                  at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
                  at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
                  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
                  at java.base/java.lang.Thread.run(Thread.java:834)
          Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getProcessCpuTime() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @41b1dccd
                  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
                  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)        at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
                  at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
                  at jenkins.metrics.impl.VMMetricProviderImpl$CpuUsageGauge.<init>(VMMetricProviderImpl.java:226)        at jenkins.metrics.impl.VMMetricProviderImpl.<init>(VMMetricProviderImpl.java:71)
                  at jenkins.metrics.impl.VMMetricProviderImpl$$FastClassByGuice$$bd4f8b03.newInstance(<generated>)
                  at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)        at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
                  at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
                  at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:89)        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
                  at hudson.ExtensionFinder$GuiceFinder$SezpozModule.onProvision(ExtensionFinder.java:567)
                  at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
                  at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
                  at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:87)
                  at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
                  at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
                  at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
                  at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
                  ... 26 more
          

          Baptiste Mathus added a comment - - edited Pretty sure this is actually unresolved, caused by https://github.com/jenkinsci/metrics-plugin/blob/d9b0eb3c576dd1aeff3bff113ca9cd0253aef40f/src/main/java/jenkins/metrics/impl/VMMetricProviderImpl.java#L226 . Will double-check and possibly reopen soonish I confirm that it does not stop Jenkins from starting though. Just seen with Jenkins 2.153-SNAPSHOT on Java 11: nov. 29, 2018 10:59:35 PM hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1 errorWARNING: Failed to instantiate Key[type=jenkins.metrics.impl.VMMetricProviderImpl, annotation=[none]]; skipping this component com.google.inject.ProvisionException: Unable to provision, see the following errors: 1) Error injecting constructor, java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getProcessCpuTime() accessible: module jdk.management does not "opens com.sun.manage ment.internal" to unnamed module @41b1dccd at jenkins.metrics.impl.VMMetricProviderImpl.<init>(VMMetricProviderImpl.java:61) 1 error at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:52) at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145) at hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1.get(ExtensionFinder.java:440) at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41) at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016) at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012) at hudson.ExtensionFinder$GuiceFinder._find(ExtensionFinder.java:402) at hudson.ExtensionFinder$GuiceFinder.find(ExtensionFinder.java:393) at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:494) at hudson.ExtensionList.load(ExtensionList.java:380) at hudson.ExtensionList.ensureLoaded(ExtensionList.java:318) at hudson.ExtensionList.iterator(ExtensionList.java:172) at jenkins.metrics.api.Metrics.afterExtensionsAugmented(Metrics.java:335) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104) at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175) at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296) at jenkins.model.Jenkins$5.runTask(Jenkins.java:1069) at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214) at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getProcessCpuTime() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @41b1dccd at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280) at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198) at java.base/java.lang.reflect.Method.setAccessible(Method.java:192) at jenkins.metrics.impl.VMMetricProviderImpl$CpuUsageGauge.<init>(VMMetricProviderImpl.java:226) at jenkins.metrics.impl.VMMetricProviderImpl.<init>(VMMetricProviderImpl.java:71) at jenkins.metrics.impl.VMMetricProviderImpl$$FastClassByGuice$$bd4f8b03.newInstance(<generated>) at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40) at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105) at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32) at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:89) at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115) at hudson.ExtensionFinder$GuiceFinder$SezpozModule.onProvision(ExtensionFinder.java:567) at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126) at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:87) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267) at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46) at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) ... 26 more

          Reopening after I confirmed this is still present in the latest version of the Metrics plugin.
          Just reproduced using the Evergreen Java 11 flavor, launched with

          Version in that case is 4.0.2.3-rc229.d9b0eb3c576d

          docker volume create jenkins-evergreen-data && \
          docker pull jenkins/evergreen:java11-docker-cloud && \
          docker run --name evergreen \
              --restart=always \
              -ti \
              -p 8080:80 \
              -v /var/run/docker.sock:/var/run/docker.sock \
              -v jenkins-evergreen-data:/evergreen/data \
              -e LOG_LEVEL=info \
              jenkins/evergreen:java11-docker-cloud
          

          Baptiste Mathus added a comment - Reopening after I confirmed this is still present in the latest version of the Metrics plugin. Just reproduced using the Evergreen Java 11 flavor, launched with Version in that case is 4.0.2.3-rc229.d9b0eb3c576d docker volume create jenkins-evergreen-data && \ docker pull jenkins/evergreen:java11-docker-cloud && \ docker run --name evergreen \ --restart=always \ -ti \ -p 8080:80 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v jenkins-evergreen-data:/evergreen/data \ -e LOG_LEVEL=info \ jenkins/evergreen:java11-docker-cloud

          I filled a PR to track this.

          I tried to focus my solution on removing the reflection, as this is almost impossible with Java 9+

          Adrien Lecharpentier added a comment - I filled a PR to track this. I tried to focus my solution on removing the reflection, as this is almost impossible with Java 9+

          So, the PR I provided to the repository seems to fix this problem but I cannot certify it because it is now facing JENKINS-54355, because of commons-beanutils.

          Adrien Lecharpentier added a comment - So, the PR I provided to the repository seems to fix this problem but I cannot certify it because it is now facing JENKINS-54355 , because of commons-beanutils .

          It seems that the PR I provided is enough. Here why I say this:

          1. I started a Jenkins instance using jenkins/jenkins:jdk11 Docker image
            1. I did install any plugin using the wizard
          2. Using the plugin manager, I installed metrics plugin, version 4.0.2.2
            1. I had to restart the instance
            2. I can confirm that I have the same issue as described here
          3. I built the changeset I provided in the PR and uploaded the hpi binary to the instance using the plugin manager
            1. during the restart, there is no error in the logs
            2. once the instance is up and running, I configured the metrics and I could see vm.cpu.load in JENKINS_URL/metrics/currentUser/metrics

          Adrien Lecharpentier added a comment - It seems that the PR I provided is enough. Here why I say this: I started a Jenkins instance using jenkins/jenkins:jdk11 Docker image I did install any plugin using the wizard Using the plugin manager, I installed metrics plugin, version 4.0.2.2 I had to restart the instance I can confirm that I have the same issue as described here I built the changeset I provided in the PR and uploaded the hpi binary to the instance using the plugin manager during the restart, there is no error in the logs once the instance is up and running, I configured the metrics and I could see vm.cpu.load in JENKINS_URL/metrics/currentUser/metrics

          I release the plugin with this fix.

          Adrien Lecharpentier added a comment - I release the plugin with this fix.

            alecharp Adrien Lecharpentier
            svanoort Sam Van Oort
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: