Jelastic java.awt.HeadlessException异常怎么处理

彭博 发布于 2012/04/04 22:41
阅读 3K+
收藏 0

今天将自己的小项目部署到了Java Paas jelastic上,其中项目需要处理图片,使用到了awt,但是报出了HeadlessException,google查到了类似的问题:http://support.jelastic.com/discussions/questions/283-ask-catalinash-file

catalina.out:

java.lang.NumberFormatException: null

	at java.lang.Integer.parseInt(Integer.java:417)

	at java.lang.Integer.parseInt(Integer.java:499)

	at Servlets.GrayscaleFacePoet.doPost(GrayscaleFacePoet.java:50)

	at Servlets.GrayscaleFacePoet.doGet(GrayscaleFacePoet.java:34)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)

	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

	at java.lang.Thread.run(Thread.java:662)

java.awt.HeadlessException

	at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)

	at java.awt.Window.<init>(Window.java:432)

	at java.awt.Frame.<init>(Frame.java:403)

	at java.awt.Frame.<init>(Frame.java:368)

	at Services.DefaultFacesReader.<init>(DefaultFacesReader.java:37)

	at Servlets.GrayscaleFacePoet.getFace(GrayscaleFacePoet.java:89)

	at Servlets.GrayscaleFacePoet.geAllPixels(GrayscaleFacePoet.java:66)

	at Servlets.GrayscaleFacePoet.doPost(GrayscaleFacePoet.java:55)

	at Servlets.GrayscaleFacePoet.doGet(GrayscaleFacePoet.java:34)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)

	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

	at java.lang.Thread.run(Thread.java:662)

代码:

package Services;

import java.awt.Frame;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.image.ColorModel;
import java.awt.image.PixelGrabber;
import java.util.ArrayList;
import java.util.List;

import ServieceInterfaces.Face;
import ServieceInterfaces.RGB;
import ServieceInterfaces.ReadFaces;

/**
 * 默认图片信息解析器
 * @author bluishoul@gmail.com
 *
 */
public class DefaultFacesReader implements ReadFaces {

	private String path;

	private Image image;

	private int[] pixels;

	private List<RGB> rgb;

	private List<Float> grey;

	private int width = 0;

	private int height = 0;

	private Frame frame = new Frame();//此处出错
......
}

求指导

@红薯 

加载中
0
彭博
彭博
难道是jelastic不支持?
0
彭博
彭博
JAVA_OPTS="-Djava.awt.headless=true"没法加 没法试哦
0
晕dows
晕dows

java.lang.NumberFormatException: null

at Servlets.GrayscaleFacePoet.doPost(GrayscaleFacePoet.java:50)


晕dows
晕dows
@bluishoul : 其他的不熟,无能为力了
彭博
彭博
这个异常是一个参数缺少导致的 没有太多影响 主要问题还是HeadlessException
彭博
彭博
谢谢提醒
0
彭博
彭博

DefaultFacesReader类代码中添加一句System.setProperty("java.awt.headless", "false");后,出现异常:

java.lang.UnsatisfiedLinkError: /usr/java/jdk1.6.0_26/jre/lib/amd64/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
	at java.lang.Runtime.load0(Runtime.java:770)
	at java.lang.System.load(System.java:1003)
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1724)
	at java.lang.Runtime.loadLibrary0(Runtime.java:823)
	at java.lang.System.loadLibrary(System.java:1028)
	at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
	at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
	at java.awt.Component.<clinit>(Component.java:566)
	at Services.DefaultFacesReader.service(DefaultFacesReader.java:89)
	at Services.DefaultFacesReader.<init>(DefaultFacesReader.java:41)
	at Servlets.GrayscaleFacePoet.getFace(GrayscaleFacePoet.java:89)
	at Servlets.GrayscaleFacePoet.geAllPixels(GrayscaleFacePoet.java:66)
	at Servlets.GrayscaleFacePoet.doPost(GrayscaleFacePoet.java:55)
	at Servlets.GrayscaleFacePoet.doGet(GrayscaleFacePoet.java:34)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:662)

返回顶部
顶部