关于JBoss日志中的报错Exception in thread "AWT-EventQueue-0"的解决记录
一、前情提要
操作系统:Windows Server 2008 R2,JDK版本:1.6.0_45,应用容器:JBoss 4.2.3 GA。所部署的应用均为Web型项目,没有任何图形相关的项目。
二、症状诊断
查看JBoss的运行日志,经常会发现如下错误日志:
10:10:54,142 ERROR [STDERR] Exception in thread "AWT-EventQueue-0" 10:10:54,156 ERROR [STDERR] java.lang.ClassCastException: sun.java2d.HeadlessGraphicsEnvironment cannot be cast to sun.a wt.Win32GraphicsEnvironment 10:10:54,158 ERROR [STDERR] at sun.awt.windows.WToolkit$3.run(WToolkit.java:737) 10:10:54,159 ERROR [STDERR] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) 10:10:54,162 ERROR [STDERR] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672) 10:10:54,167 ERROR [STDERR] at java.awt.EventQueue.access$400(EventQueue.java:81) 10:10:54,168 ERROR [STDERR] at java.awt.EventQueue$2.run(EventQueue.java:633) 10:10:54,168 ERROR [STDERR] at java.awt.EventQueue$2.run(EventQueue.java:631) 10:10:54,170 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method) 10:10:54,170 ERROR [STDERR] at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.jav a:87) 10:10:54,173 ERROR [STDERR] at java.awt.EventQueue.dispatchEvent(EventQueue.java:642) 10:10:54,173 ERROR [STDERR] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) 10:10:54,176 ERROR [STDERR] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) 10:10:54,176 ERROR [STDERR] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) 10:10:54,178 ERROR [STDERR] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) 10:10:54,179 ERROR [STDERR] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) 10:10:54,179 ERROR [STDERR] at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
作为运维看到错误日志都是很不爽的,所以我飞要消除之!
三、资料查找
Google上查到两份资料,很有用,按照其中说明,去掉了-Djava.awt.headless = true,在我本机测试没有问题,将在服务器上使用,并继续观察。
资料一:https://confluence.atlassian.com/fishkb/getting-a-sun-java2d-headlessgraphicsenvironment-cannot-be-cast-to-sun-awt-win32graphicsenvironment-error-on-startup-178259867.html
资料二:http://dikar.iteye.com/blog/1417625