Could not initialize class javax.imageio.ImageIO

大兔子大兔子 提交于 2019-11-29 14:46:52
ranjeetcao

Got fixed for me by adding following JVM option.

JAVA_OPTS="-Djava.awt.headless=true -Dawt.toolkit=sun.awt.HToolkit"
Nando

Ok so I fixed this issue =)

  1. I removed OpenJDK from Linux distribution and installed Oracle Java 7 > u25 by hand. (Good tutorial: http://de.wikihow.com/Installation-von-Oracle-Java-unter-Ubuntu-Linux)

  2. Then I added an ApplicationListener which loads the sunToolkit by hand (because AppContext is always null for some reason)

    @SuppressWarnings("restriction")
    public class ContextConfiguration implements ApplicationListener<ContextRefreshedEvent> {
        @Override
        public void onApplicationEvent(ContextRefreshedEvent arg0) {
            //refresh awt context
            if(AppContext.getAppContext() == null) {
                SunToolkit.createNewAppContext();
            }
        }
    }
    

Thanks at haraldK =)

James

I have tomcat 8.5 and used it with log4j as a general logger. I changed the tomcat-juli.jar in the $CATALINA_Home/bin directory. and I got this error. I changed to the original tomcat-juli.jar ( a link ../../java/tomcat8-juli.jar) and it worked again !

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!