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.font.SunFontManager exception when moving from oracle jdk 8 to corretto jdk 1.8.0_362. #466

Open
sagar21304 opened this issue May 25, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@sagar21304
Copy link

Describe the bug

java.lang.NoClassDefFoundError: sun.font.SunFontManager exception when moving from oracle jdk to corretto jdk 1.8.0_362.

To Reproduce

Build a jar which uses sun.font.SunFontManager with oracle jdk 8 and then migrate to corretto jdk jdk 1.8.0_362.

Expected behavior

It should not throw an java.lang.NoClassDefFoundError: sun.font.SunFontManager exception

Screenshots

May 18, 2023 7:14:15 AM
SEVERE: java.lang.NoClassDefFoundError: sun.font.SunFontManager
May 18, 2023 7:14:15 AM
SEVERE: at java.lang.Class.forName0(Native Method)
May 18, 2023 7:14:15 AM
SEVERE: at java.lang.Class.forName(Class.java:348)
May 18, 2023 7:14:15 AM
SEVERE: at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
May 18, 2023 7:14:15 AM
SEVERE: at java.security.AccessController.doPrivileged(Native Method)
May 18, 2023 7:14:15 AM
SEVERE: at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
May 18, 2023 7:14:15 AM
SEVERE: at sun.java2d.SunGraphicsEnvironment.getFontManagerForSGE(SunGraphicsEnvironment.java:190)
May 18, 2023 7:14:15 AM
SEVERE: at sun.java2d.SunGraphicsEnvironment.getAllFonts(SunGraphicsEnvironment.java:209)

Platform information

OS: Windows Server 2019 Datacenter ,64 bit ]
Version : java -version

openjdk version "1.8.0_362"
OpenJDK Runtime Environment Corretto-8.362.08.1 (build 1.8.0_362-b08)
OpenJDK Server VM Corretto-8.362.08.1 (build 25.362-b08, mixed mode)

Additional context

It seems sun.font.SunFontManager class is not part of corretto jre 1.8.0_362. However, its working with corretto 11 without any problem.

Expectation: How to load sun.font.* with corretto jre 1.8.0_362 to resolve this issue? What should I do to resolve this?

@sagar21304 sagar21304 added the bug Something isn't working label May 25, 2023
@benty-amzn
Copy link
Contributor

I've done a quick local test and wasn't able to reproduce this issue.
The class is part of corretto-8, located at SunFontManager.java.

Is there any additional information you can share that might help reproduce the issue? A minimal code snippet and any command line flags you're using to launch your application might help.

@sagar21304
Copy link
Author

sagar21304 commented May 26, 2023

Thank you for quick analysis and response. Yes. I also verified that SunFontmanager is part of corretto 8 jdk.
But question is, is it part of corretto-8 jre? I mean is it packaged into corretto 8 jre?
If yes. In which dll or jar or exe it is packaged? If no, what would be feasible way to resolve this issue? could you confirm?
When I am compiling a jar with "1.8.0_362" corretto jdk and using corretto 11 jre , its working fine. But it's not working with same version of "1.8.0_362" corretto jre.
Is there any specific setting or configuration or package or font related stuff is required?

@sagar21304
Copy link
Author

One more input: This an runtime exception i am getting. I am able to compile code successfully.

@eastig
Copy link
Member

eastig commented May 30, 2023

Hi @sagar21304
I checked https://corretto.aws/downloads/resources/8.372.07.1/amazon-corretto-8.372.07.1-windows-x86-jre.zip.
SunFontManager class is present in lib/rt.jar:

rt.jar/uzip://sun/font:
SunFontManager.class 48857 Apr 17 23:01

You need to check how you run your application, especially whether you redefine classpaths.

@sagar21304
Copy link
Author

sagar21304 commented Jun 1, 2023

Hi @eastig,

Thank you for your input. What should be the classpath to access SunFontManager.class? Could you please confirm?

@sagar21304
Copy link
Author

sagar21304 commented Jun 2, 2023

Hi @eastig, there is no change in classpath. Is there any specific change required for corretto 8 classpath?

We are loading a jar file using jni api in c++ apllcation.This a classpath passing to jvm.
Djava.class.path=..\lib;..\lib\VCSGui.jar;..\lib\VxHelpViewer.jar;..\jre\lib\rt.jar;..\lib\gui_images.jar;
..\lib\sounds.jar;..\lib\VxHelpViewerl10n.jar;..\lang;C:\Program Files (x86)\VVVVVV\Cluster Manager\EAT\bin\AtWrapper.jar

Its working fine with corretto 11 jre. But its not working with corretto 8 jre. Is there anything specific to corretto 8?

@eastig
Copy link
Member

eastig commented Jun 9, 2023

Hi @sagar21304,

Do you use JNI_CreateJavaVM?

I think you might have some configuration issues with it.

Djava.class.path=..\lib;..\lib\VCSGui.jar;..\lib\VxHelpViewer.jar;..\jre\lib\rt.jar;..\lib\gui_images.jar;

I see you have rt.jar in the java.class.path. rt.jar is a Java system jar file and java.class.path is not intended for it. java.class.path is for user's classes/jars.

Can you trace class loading?

@eastig
Copy link
Member

eastig commented Jun 9, 2023

Is there anything specific to corretto 8?

There is nothing specific regarding classpath needed for corretto 8.

@sagar21304
Copy link
Author

sagar21304 commented Jun 12, 2023

Hi @eastig,

Thank you for your response. Yes. We are using JNI_CreateJavaVM. After removing rt.jar from the java.class.path its not working with corretto 8 jre.

@jamesmancz
Copy link

@sagar21304 We're experiencing the same issue; did you find a solution/workaround?

@jamesmancz
Copy link

Found a fix for this. Simply install the fontconfig Linux package on your VM/in your container image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants