我设法破坏了一个工作应用程序,但无法解决如何修复它。
我有一个 Java Web 应用程序,它在 Eclipse(春季 STS 版本)内的 Windows7 机器上的“tc 服务器”上运行。
该应用程序将使用 java.awt.robot 执行屏幕捕获,并在后续页面上显示捕获的图像。
到目前为止一切顺利,我已经能够从屏幕上收集缓冲图像并将其显示在网络应用程序的后续页面上。
然后我以某种方式破坏了网络应用程序,可能正在加载 Android SDK 和 Eclipse 工具。
现在,我收到了 Robot 的异常,因为它无法在 HeadlessEnvironment 中运行。谷歌搜索表明 headlessEnvironment 是在没有屏幕和键盘的情况下运行的,但我两者都有。该应用程序以前可以正常工作,但从未遇到 HeadlessEnvironment。
如果我调试并显示 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 工具集。这遇到了 HeadlessEnvironment 问题,所以我已经恢复到我原来的 eclipse 版本,现在也有同样的问题。
我现在感觉很卡,大多数搜索都告诉我如何打开无头模式,谁能解释如何再次关闭无头模式?
非常感谢 !
<------------- 编辑:添加了堆栈跟踪 ------------------------------- ------------------------------------>
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)