码迷,mamicode.com
首页 > Web开发 > 详细

weblogic环境,应用上传图片报Could not initialize class sun.awt.X11.XToolkit

时间:2015-06-04 15:44:11      阅读:1961      评论:0      收藏:0      [点我收藏+]

标签:

问题描述

遇到的问题是在weblogic环境,应用在上传图片的时候报Could not initialize class sun.awt.X11.XToolkit 错误。

具体错误如下

17:57:02 [AWT-EventQueue-2] DEBUG - Leaving class nc.ui.hi.psndoc.action.SavePsndocAction.actionPerformed 
Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at java.awt.Toolkit$2.run(Toolkit.java:834)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
	at javax.swing.ImageIcon.<init>(ImageIcon.java:236)
	at nc.pub.tools.VOUtils.transPreviewPhoto(VOUtils.java:212)
	at nc.impl.hi.psndoc.PsndocValidator.setPreviewPhoto(PsndocValidator.java:1338)
	at nc.impl.hi.psndoc.PsndocValidator.adjustPsndoc(PsndocValidator.java:1320)
	at nc.impl.hi.psndoc.PsndocValidator.validate(PsndocValidator.java:819)
	at nc.impl.hi.psndoc.PsndocServiceImpl.savePsndoc(PsndocServiceImpl.java:1616)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at nc.bs.framework.aop.rt.MethodProceedingJoinpoint$3.invoke(MethodProceedingJoinpoint.java:74)
	at nc.bs.framework.aop.rt.MethodProceedingJoinpoint.proceed(MethodProceedingJoinpoint.java:184)
	at nc.bs.framework.server.SecurityAspect.aroundMethod1(SecurityAspect.java:45)
	at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at nc.bs.framework.aop.rt.AdviceHolder.invoke(AdviceHolder.java:182)
	at nc.bs.framework.aop.rt.MethodProceedingJoinpoint.proceed(MethodProceedingJoinpoint.java:129)
	at nc.bs.framework.aop.rt.MethodProceedingJoinpoint.proceed(MethodProceedingJoinpoint.java:135)
	at nc.bs.aop.log.BusilogAspect.aroundMethod(BusilogAspect.java:75)
	at sun.reflect.GeneratedMethodAccessor1769.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at nc.bs.framework.aop.rt.AdviceHolder.invoke(AdviceHolder.java:182)
	at nc.bs.framework.aop.rt.MethodProceedingJoinpoint.proceed(MethodProceedingJoinpoint.java:129)
	at nc.bs.framework.aop.rt.MethodProceedingJoinpoint.proceed(MethodProceedingJoinpoint.java:135)
	at nc.bs.framework.aop.rt.AspectedProxy.invoke(AspectedProxy.java:59)
	at $Proxy519.savePsndoc(Unknown Source)
	at nc.itf.hr.hi.HRhiEJBEjbBean.savePsndoc(HRhiEJBEjbBean.java:2812)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
	at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
	at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy514.savePsndoc(Unknown Source)

解决办法

在启动java服务器的时候,在启动参数中加入以下参数

-Djava.awt.headless=true

headless问题探讨

关于java服务器的headless模式,oracle官网的说明为:

http://www.oracle.com/technetwork/articles/javase/headless-136834.html

其中很多概念我也不是很理解

大致意思就是,在java服务器端,有许多图形界面的处理函数,需要调用显示器,鼠标键盘这些设备,但有些处理函数则不需要,如果设置了这个headless之后,图形界面的处理和渲染是分开的,用于生成图片的工作放在服务器端进行,生成后将编码传到客户端,再在客户端进行渲染和显示。

这主要用了服务器端的高计算能力,然后把需要调用显示器相关的工作传到客户端去执行。

以上的错误本身是要初始化X11服务器,然后用X11的工具箱去做图形生成计算这等事,但是X11初始化失败,应该是X11的安装环境有问题,于是可以设置java参数

-Djava.awt.headless=true

这个参数,使用java自带的这个服务器工具箱。


以上是我的理解,对错有待验证。


weblogic环境,应用上传图片报Could not initialize class sun.awt.X11.XToolkit

标签:

原文地址:http://blog.csdn.net/jx_jy/article/details/46361787

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!