`
xumingrencai
  • 浏览: 1177174 次
文章分类
社区版块
存档分类
最新评论

问题描述:[07-5-28 9:57:15:191 CST] f6eadb0 WebGroup E SRVE0026E: [Servlet 错误]-[sun/awt/motif/MToolkit]:java.lang.NoClassDefFou

 
阅读更多

出自:http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_19252

源问题如下:

[07-5-28 9:57:15:191 CST] f6eadb0 WebGroup E SRVE0026E: [Servlet 错误]-[sun/awt/motif/MToolkit]:java.lang.NoClassDefFoundError: sun/awt/motif/MToolkit
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java(Compiled Code))
at java.awt.Toolkit$2.run(Toolkit.java:796)
at java.security.AccessController.doPrivileged1(Native Method)
at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code))
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:787)
at javax.swing.ImageIcon.<init>(ImageIcon.java:111)
at javax.swing.ImageIcon.<init>(ImageIcon.java:137)
at com.yc.ycportal.util.WaterMark.createMark(WaterMark.java:21)
at com.yc.ycportal.util.Upload.doPost(Upload.java:106)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java(Compiled Code))
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java(Compiled Code))
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java(Compiled Code))
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

解决问题源文章如下:

Reason

This is most likely because the server doesn't have a graphical subsystem (i.e. a graphics card and monitor). The Flex server uses Java's AWT (Abstract Window Toolkit) to implement compile time image embedding and SVG. By default, the Java Virtual Machine tries to use the hardware-based graphical capabilities of the machine to implement AWT. For servers without a graphical interface, the above error will be thrown.

Solution

To resolve this issue, set the system propertyjava.awt.headless to true so that the JVM will implement AWT in software, rather than attempting to use non-existent hardware-based graphics.

Note: java.awt.headless is only available with JDK 1.4 and above. It is not available on previous versions of the JDK.

There are two ways to set java.awt.headless to true:

  • Using the command line:

    -Djava.awt.headless=true
  • Configuring in /WEB-INF/flex/flex-config.xml as:
    <compiler><headless-server>true</headless-server></compiler>
    Note: java.awt.headless should only be set to true if no graphics card exists on your machine. If you set this property to true when a graphics card exists, it will cause the cfchart tag in ColdFusion to throw an error.

If you are using WebSphere on Linux, you must set -Djava.awt.headless=true in the WebSphere administrator. Select Application Servers >your server instance> Process Definition > Java Virtual Machine > Generic JVM arguments, then add the setting.

You may see the following error if it is not set when you request the sample data model:

sun/awt/motif/MToolkit
Technical Information:
HTTP Status Code: 500
Exception Type: class java.lang.NoClassDefFoundError
Servlet Name: FlexMxmlServlet
Exception java.lang.NoClassDefFoundError 
sun/awt/motif/MToolkit (View stack trace)Actual Results:
HTTP Status Code: 500Exception Type: class java.lang.NoClassDefFoundError Servlet
Name: FlexMxmlServlet

After you restart your server, the sample should work. If you still see the error, delete all your temporary internet files so that your browser is not serving up the cached page.

翻译如下:问题产生的原因最大可能是因为服务器没有一个图形设备。JAVA虚拟机试图通过硬件图形设备来实现AWT,所以服务器没有图形设备接口的就会抛出上面的错误。

解决办法:为了解决这个问题,设置系统属性java.awt.headless 为:true 从而使JVM用软件来实现SWT,而不是尝试使用已经存在的硬件来实现。

注意:java.awt.headless 这个属性仅仅当JDK大于等于1.4才可以使用。早期版本没有。

两种方法来实现设置java.awt.headless 这个为true

1.使用命令行:

-Djava.awt.headless=true

2.配置/WEB-INF/flex/flex-config.xml 如下:

<compiler><headless-server>true</headless-server></compiler>
注意:没有图形设备时应该设置成true;如果有图形设备会引起代码溢出错误
如果使用的是linux websphere,你必须设置-Djava.awt.headless=true 在websphere的管理控制台。
应用程序服务器 > server1 > 进程定义 > 一般 JVM 自变量
-Djava.awt.headless=true 
修改后重新启动服务器,就应该好了,如果还有问题清除临时文件,就应该没有问题了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics