Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JvmDefaultGCMetricsLogger cannot access class sun.management.ManagementFactoryHelper #15539

Closed
mattisonchao opened this issue May 11, 2022 · 0 comments · Fixed by #15540
Closed
Assignees
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@mattisonchao
Copy link
Member

Describe the bug
The following error was found when running test with JDK 17.

java.lang.IllegalAccessException: class org.apache.pulsar.common.stats.JvmDefaultGCMetricsLogger cannot access class sun.management.ManagementFactoryHelper (in module java.management) because module java.management does not export sun.management to unnamed module @7c29daf3
	at jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392) ~[?:?]
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:560) ~[?:?]
	at org.apache.pulsar.common.stats.JvmDefaultGCMetricsLogger.<clinit>(JvmDefaultGCMetricsLogger.java:51) ~[classes/:?]
	at org.apache.pulsar.common.stats.JvmMetrics.create(JvmMetrics.java:73) ~[classes/:?]
	at org.apache.pulsar.broker.stats.MetricsGenerator.<init>(MetricsGenerator.java:39) ~[classes/:?]
	at org.apache.pulsar.broker.PulsarService.start(PulsarService.java:802) ~[classes/:?]
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732) ~[?:?]
	at org.mockito.internal.util.reflection.InstrumentationMemberAccessor$Dispatcher$ByteBuddy$5rfVl8Ar.invokeWithArguments(Unknown Source) ~[?:?]
	at org.mockito.internal.util.reflection.InstrumentationMemberAccessor.invoke(InstrumentationMemberAccessor.java:239) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.util.reflection.ModuleMemberAccessor.invoke(ModuleMemberAccessor.java:55) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice.tryInvoke(MockMethodAdvice.java:333) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice.access$500(MockMethodAdvice.java:60) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice$RealMethodCall.invoke(MockMethodAdvice.java:253) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.invocation.InterceptedInvocation.callRealMethod(InterceptedInvocation.java:142) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.stubbing.answers.CallsRealMethods.answer(CallsRealMethods.java:45) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.Answers.answer(Answers.java:99) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:110) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:29) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:34) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:82) ~[mockito-core-3.12.4.jar:?]
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice.handle(MockMethodAdvice.java:151) ~[mockito-core-3.12.4.jar:?]
	at org.apache.pulsar.broker.PulsarService.start(PulsarService.java:629) ~[classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.startBrokerWithoutAuthorization(MockedPulsarServiceBaseTest.java:310) ~[test-classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.startBroker(MockedPulsarServiceBaseTest.java:302) ~[test-classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.startBroker(MockedPulsarServiceBaseTest.java:282) ~[test-classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.init(MockedPulsarServiceBaseTest.java:192) ~[test-classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.internalSetup(MockedPulsarServiceBaseTest.java:117) ~[test-classes/:?]
	at org.apache.pulsar.broker.service.BrokerTestBase.baseSetup(BrokerTestBase.java:39) ~[test-classes/:?]
	at org.apache.pulsar.client.impl.MessageIdTest.setup(MessageIdTest.java:56) ~[test-classes/:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132) ~[testng-7.3.0.jar:?]
	at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61) ~[testng-7.3.0.jar:?]
	at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:366) ~[testng-7.3.0.jar:?]
	at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:320) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:701) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174) ~[testng-7.3.0.jar:?]
	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) ~[testng-7.3.0.jar:?]
	at java.util.ArrayList.forEach(ArrayList.java:1511) [?:?]
	at org.testng.TestRunner.privateRun(TestRunner.java:764) [testng-7.3.0.jar:?]
	at org.testng.TestRunner.run(TestRunner.java:585) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.run(SuiteRunner.java:286) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) [testng-7.3.0.jar:?]
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218) [testng-7.3.0.jar:?]
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) [testng-7.3.0.jar:?]
	at org.testng.TestNG.runSuites(TestNG.java:1069) [testng-7.3.0.jar:?]
	at org.testng.TestNG.run(TestNG.java:1037) [testng-7.3.0.jar:?]
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66) [testng-rt.jar:?]
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109) [testng-rt.jar:?]
2022-05-11T14:28:39,916 - INFO  - [main:PulsarService@1115] - Starting load management service ...
2022-05-11T14:28:39,949 - INFO  - [metadata-store-11-1:ResourceLockImpl@165] - Acquired resource lock on /loadbalance/brokers/localhost:64190
2022-05-11T14:28:39,987 - INFO  - [main:PulsarService@1119] - Starting load balancer
2022-05-11T14:28:39,999 - INFO  - [main:PulsarService@1058] - SLA Namespace = sla-monitor/test/localhost:64190 doesn't exist.
2022-05-11T14:28:40,021 - INFO  - [main:PulsarService@845] - messaging service is ready, bootstrap_seconds=8
2022-05-11T14:28:40,021 - INFO  - [main:PulsarService@846] - messaging service is ready, bootstrap service port = 64190, tls-port = Optional[64191], broker url= pulsar://localhost:64183, broker tls url= pulsar+ssl://localhost:64184, cluster=test, configs=org.apache.pulsar.broker.ServiceConfiguration@569d7074
2022-05-11T14:28:40,022 - INFO  - [main:MockedPulsarServiceBaseTest@311] - Pulsar started. brokerServiceUrl: pulsar://localhost:64183 webServiceAddress: http://localhost:64190
2022-05-11T14:28:40,372 - WARN  - [main:DnsServerAddressStreamProviders@70] - Can not find io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider in the classpath, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.
2022-05-11T14:28:40,379 - WARN  - [main:DnsResolverUtil@51] - Cannot get DNS TTL settings from sun.net.InetAddressCachePolicy class
java.lang.IllegalAccessException: class org.apache.pulsar.common.util.netty.DnsResolverUtil cannot access class sun.net.InetAddressCachePolicy (in module java.base) because module java.base does not export sun.net to unnamed module @7c29daf3
	at jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392) ~[?:?]
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:560) ~[?:?]
	at org.apache.pulsar.common.util.netty.DnsResolverUtil.<clinit>(DnsResolverUtil.java:46) ~[classes/:?]
	at org.apache.pulsar.client.impl.ConnectionPool.createAddressResolver(ConnectionPool.java:118) ~[classes/:?]
	at org.apache.pulsar.client.impl.ConnectionPool.lambda$new$1(ConnectionPool.java:106) ~[classes/:?]
	at java.util.Optional.orElseGet(Optional.java:364) ~[?:?]
	at org.apache.pulsar.client.impl.ConnectionPool.<init>(ConnectionPool.java:106) ~[classes/:?]
	at org.apache.pulsar.client.impl.ConnectionPool.<init>(ConnectionPool.java:75) ~[classes/:?]
	at org.apache.pulsar.client.impl.ConnectionPool.<init>(ConnectionPool.java:70) ~[classes/:?]
	at org.apache.pulsar.client.impl.PulsarClientImpl.<init>(PulsarClientImpl.java:186) ~[classes/:?]
	at org.apache.pulsar.client.impl.PulsarClientImpl.<init>(PulsarClientImpl.java:144) ~[classes/:?]
	at org.apache.pulsar.client.impl.ClientBuilderImpl.build(ClientBuilderImpl.java:63) ~[classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.createNewPulsarClient(MockedPulsarServiceBaseTest.java:151) ~[test-classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.newPulsarClient(MockedPulsarServiceBaseTest.java:143) ~[test-classes/:?]
	at org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.internalSetup(MockedPulsarServiceBaseTest.java:129) ~[test-classes/:?]
	at org.apache.pulsar.broker.service.BrokerTestBase.baseSetup(BrokerTestBase.java:39) ~[test-classes/:?]
	at org.apache.pulsar.client.impl.MessageIdTest.setup(MessageIdTest.java:56) ~[test-classes/:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132) ~[testng-7.3.0.jar:?]
	at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61) ~[testng-7.3.0.jar:?]
	at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:366) ~[testng-7.3.0.jar:?]
	at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:320) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:701) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174) ~[testng-7.3.0.jar:?]
	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) ~[testng-7.3.0.jar:?]
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) ~[testng-7.3.0.jar:?]
	at java.util.ArrayList.forEach(ArrayList.java:1511) [?:?]
	at org.testng.TestRunner.privateRun(TestRunner.java:764) [testng-7.3.0.jar:?]
	at org.testng.TestRunner.run(TestRunner.java:585) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunner.run(SuiteRunner.java:286) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) [testng-7.3.0.jar:?]
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) [testng-7.3.0.jar:?]
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218) [testng-7.3.0.jar:?]
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) [testng-7.3.0.jar:?]
	at org.testng.TestNG.runSuites(TestNG.java:1069) [testng-7.3.0.jar:?]
	at org.testng.TestNG.run(TestNG.java:1037) [testng-7.3.0.jar:?]
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66) [testng-rt.jar:?]
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109) [testng-rt.jar:?]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant