[Solved] Weblogic error: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11G

Error message: Java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11G

After looking at the background, locate the error code as follows

//Save a thumbnail image locally
BufferedImagesrc=ImageIO.read(file2);
FilelocalDir=newFile(GlobalConstants.SAVE_PATH+GlobalConstants.SMALL_IMAGE_SAVE_PATH);
if(!localDir.exists()){
    localDir.mkdirs();
}
//The following code starts reporting errors
BufferedImageoutImg=newBufferedImage(60,60,BufferedImage.TYPE_INT_RGB);
outImg.getGraphics().drawImage(src,0,0,60,60,null);

Solution:

Open the setDomainEnv.sh configuration file under the weblogic domain service bin

Add parameters in the following positions:

JAVA_OPTIONS="${JAVA_OPTIONS} -Djava.awt.headless=true " ​
export JAVA_OPTIONS

Similar Posts: