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

java.lang.NoClassDefFoundError: sun.management.Util in runtime on JDK 17 #3875

Closed
phejl opened this issue Oct 6, 2021 · 4 comments · Fixed by #3949
Closed

java.lang.NoClassDefFoundError: sun.management.Util in runtime on JDK 17 #3875

phejl opened this issue Oct 6, 2021 · 4 comments · Fixed by #3949
Assignees
Labels
bug native-image spring spring related issue

Comments

@phejl
Copy link

phejl commented Oct 6, 2021

Describe the issue
ManagementFactory.getPlatformMBeanServer in native-image (JDK 17) throws NoClassDefFoundError.

Steps to reproduce the issue
Please include both build steps as well as run steps
1.

public class Test {
    public static void main(String[] args) {
        System.out.println(java.lang.management.ManagementFactory.getPlatformMBeanServer());
    }
}
  1. javac Test.java
  2. native-image --no-fallback --allow-incomplete-classpath Test
  3. ./test
  4. NoClassDefFoundError

Describe GraalVM and your environment:

openjdk version "17" 2021-09-14
OpenJDK Runtime Environment GraalVM CE 21.3.0-dev (build 17+35-jvmci-21.3-b03)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0-dev (build 17+35-jvmci-21.3-b03, mixed mode, sharing)
  • JDK major version: 17
  • OS: Linux
  • Architecture: AMD64

More details

Exception in thread "main" java.lang.NoClassDefFoundError: sun.management.Util
	at com.oracle.svm.core.jdk.management.SubstrateCompilationMXBean.getObjectName(SubstrateCompilationMXBean.java:47)
	at com.oracle.svm.core.jdk.management.ManagementSupport.addMXBean(ManagementSupport.java:267)
	at com.oracle.svm.core.jdk.management.ManagementSupport.getPlatformMBeanServer(ManagementSupport.java:259)
	at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:45)
	at Test.main(Test.java:4)
@phejl
Copy link
Author

phejl commented Oct 6, 2021

It seems this can be workarounded by adding -J--add-exports=java.management/sun.management=ALL-UNNAMED as an argument to native-image

@rodrigar-mx rodrigar-mx self-assigned this Oct 8, 2021
@rodrigar-mx
Copy link
Contributor

Thanks for reporting this issue. I will take a closer look into it and get back to you.

@rodrigar-mx
Copy link
Contributor

Hi @phejl. I have raised this issue internally with the native-image team. An answer will be provided accordingly.

@sdeleuze
Copy link
Collaborator

Please tag this issue with spring label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug native-image spring spring related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants