无法公开 long com.sun.management.internal.OperatingSystemImpl.getOpenFileDescriptorCount()

SKR*_*SKR 7 java maven java-11

我在 Java 11 的服务器日志中收到以下错误。有什么解决方案吗?

[2019-05-02 18:06:18 IST] [] ERROR com.codahale.metrics.ScheduledReporter [SID= UID= BGCD=] - Exception thrown from Slf4jReporter#report. Exception was suppressed.
java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getOpenFileDescriptorCount() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @489448ac
    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 deployment.myPage.war//com.codahale.metrics.jvm.FileDescriptorRatioGauge.invoke(FileDescriptorRatioGauge.java:48)
    at deployment.myPage.war//com.codahale.metrics.jvm.FileDescriptorRatioGauge.getRatio(FileDescriptorRatioGauge.java:35)
    at deployment.myPage.war//com.codahale.metrics.RatioGauge.getValue(RatioGauge.java:64)
    at deployment.myPage.war//com.codahale.metrics.RatioGauge.getValue(RatioGauge.java:11)
    at deployment.myPage.war//com.codahale.metrics.DerivativeGauge.getValue(DerivativeGauge.java:23)
    at deployment.myPage.war//com.codahale.metrics.Slf4jReporter.logGauge(Slf4jReporter.java:306)
    at deployment.myPage.war//com.codahale.metrics.Slf4jReporter.report(Slf4jReporter.java:220)
    at deployment.myPage.war//com.codahale.metrics.ScheduledReporter.report(ScheduledReporter.java:243)
    at deployment.myPage.war//com.codahale.metrics.ScheduledReporter$1.run(ScheduledReporter.java:182)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
Run Code Online (Sandbox Code Playgroud)

sen*_*vic 7

您项目的依赖项之一是尝试访问已移至内部 java 模块且不再公开的 jvm api。

使用以下标志运行应用程序应该可以解决问题:

--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
Run Code Online (Sandbox Code Playgroud)