我設法打破了一個正在運行的應用程序,並且無法解決如何解決這個問題。如何關閉windows7上的無頭圖形環境
我有一個Java Web應用程序可以運行在從Eclipse中一個Windows7的盒子「TC服務器」(春天STS版)。
該應用程序將使用java.awt.Robot中進行屏幕截圖,並在後續頁面上顯示拍攝的圖像。
到目前爲止,我已經能夠從屏幕上收集緩衝圖像並將其顯示在網頁應用程序的後續頁面中。
然後我以某種方式打破了Web應用程序,可能是加載Android SDK和Eclipse工具。
現在,我正在從Robot獲取異常,因爲它無法在無頭環境中運行。 谷歌搜索表明,無頭環境適用於沒有屏幕和鍵盤的情況下運行,但我同時擁有。 該應用程序以前沒有遇到過無頭環境。
如果我調試並顯示GraphicsEnvironment;
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
我得到一個基於Win32GraphicsEnvironment的HeadlessGraphicsEnvironment對象。
同時:
String nm = java.security.AccessController.doPrivileged
(new sun.security.action.GetPropertyAction("java.awt.graphicsenv", null));
System.out.println("java.awt.graphicsenv = " + nm);
給
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
我的可憐的升級到Android使我原本放棄升級和重新安裝最新的SpringSource工具套件。這遇到了無頭環境問題,所以我已經恢復到我的原始版本的eclipse,現在它也有同樣的問題。
現在我覺得比較卡住,而且大多數搜索都告訴我如何打開Headless模式,任何人都可以解釋如何再次關閉無頭模式?
非常感謝!
< -------------編輯:添加堆棧跟蹤--------------------------- --------------------------->
05-Apr-2012 18:42:51 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [viewerServlet] in context with path [/WebView] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: java.awt.AWTException: headless environment] with root cause
java.awt.AWTException: headless environment
at java.awt.Robot.<init>(Robot.java:75)
at uk.co.fred.MSWindowsHandler.WindowHandlerUtilities.setupRobot(WindowHandlerUtilities.java:191)
at uk.co.fred.MSWindowsHandler.WindowHandlerUtilities.scanWindow(WindowHandlerUtilities.java:71)
at uk.co.fred.Scanner.ScanServiceImpl.scanScreenToBufferedImage(ScanServiceImpl.java:66)
at uk.co.fred.viewer.controller.scan.control.ScanControlController.postPage_control_Scan(ScanControlController.java:57)
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 org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.traceNextValve(HttpRequestOperationCollectionValve.java:112)
at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:94)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
我們需要的堆棧跟蹤的youre看! – davidfrancis 2012-04-04 23:40:53
好的,沒問題。最初的AWT異常之前被困住了,但爲了清晰起見,我將它作爲一個runtimeException拋出。 – user582011 2012-04-05 17:52:37