java.lang.NoClassDefFoundError: Could not initialize class javax.imageio.ImageIO jboss EAP 6

狂风中的少年 提交于 2020-01-03 13:57:03

问题


We are using the JBoss EAP 6; Everything works well till production environment. But Post deployment in production, we are getting the below error:

java.lang.NoClassDefFoundError: Could not initialize class javax.imageio.ImageIO 

The error happening in one of the servlet where we are creating the Captcha. This is the line where this error is happening :

ImageIO.write(bufferedImage, "png", baos); 

Here is the stack trace for the Error :

Server:server-three] Caused by: java.lang.NoClassDefFoundError: Could not initialize class javax.imageio.ImageIO
[Server:server-three]   at org.fwcms.tc.servlet.Captcha.doGet(Captcha.java:150) [classes:]
[Server:server-three]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec.jar:1.0.2.Final-redhat-1]
[Server:server-three]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec.jar:1.0.2.Final-redhat-1]
[Server:server-three]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb.jar:7.2.2.Final-redhat-1]
[Server:server-three]   ... 36 more

This is not happening any other environments. We are deploying the app as ear. Any suggestion/pointers in resolving this will help me a lot.

Thank you in advance.

Regards, Manjunath


回答1:


I found solution. You have to inicializate ImageIO before other operations. You can do this by adding:

static {
        ImageIO.scanForPlugins();
}

eg into your Main class.



来源:https://stackoverflow.com/questions/20789546/java-lang-noclassdeffounderror-could-not-initialize-class-javax-imageio-imageio

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