Tag: 无头

Mac OS X Server上的Java:游戏结束?

作为一名目前正在开发使用Java / Tomcat后端的Web应用程序的开发人员,Apple最近宣布弃用Java令我感到震惊。 主要是因为我计划在Mac OS X Server上托管这个Web应用程序(已经在10.5上,很快将在10.6上)。 来自http://www.appleoutsider.com/2010/10/22/java/ : 自英特尔过渡以来,为达尔文构建服务器虚拟机几乎是微不足道的。 这是真的吗? 是否有某个文档描述了如何为Mac OS X Server构建无头Java VM?

如何修复NoClassDefFoundError:CircularOutputStream错误?

我只是为Selenium WebDriver(又名Selenium 2)为无头测试创建了一个简单的maven项目。 我在pom.xml中添加了PhantomJS驱动程序依赖项和其他依赖项: com.github.detro phantomjsdriver 1.2.0 但它得到了错误: java.lang.NoClassDefFoundError: org/openqa/selenium/io/CircularOutputStream at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:60) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at jp.co.skygate.home.HomePageLogin.setUp(HomePageLogin.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at 只是从pom.xml中删除PhantomJS依赖项解决了问题并且执行正常。 有人能帮我找到问题吗? 提前致谢。

Java无头双三次图像resize

我需要执行java图像裁剪并在没有X服务器的情况下resize。 我尝试了几种方法。 下面的第一个方法有效,但输出一个相当难看的resize的图像(可能使用最近邻居算法resize: static BufferedImage createResizedCopy(Image originalImage, int scaledWidth, int scaledHeight, boolean preserveAlpha) { int imageType = preserveAlpha ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB; BufferedImage scaledBI = new BufferedImage(scaledWidth, scaledHeight, imageType); Graphics2D g = scaledBI.createGraphics(); if (preserveAlpha) { g.setComposite(AlphaComposite.Src); } g.drawImage(originalImage, 0, 0, scaledWidth, scaledHeight, null); g.dispose(); return scaledBI; } 所以我决定使用bicubic resize,它可以提供更好的结果: public static BufferedImage createResizedCopy(BufferedImage source, […]

由于来自容器启动的AM容器exception,无头环境中的MapReduce作业失败了N次

在MacOSX中运行地图减少无头环境中的作业时(例如,当作为特定用户ssh时运行作业时),我得到以下exception或类似的东西…… 2013-12-04 15:08:28,513 WARN org.apache.hadoop.yarn.server.resourcemanager.RMAuditLogger: USER=hadoop OPERATION=Application Finished – Failed TARGET=RMAppManager RESULT=FAILURE DESCRIPTION=App failed with state: FAILED PERMISSIONS=Application application_1386194876944_0001 failed 2 times due to AM Container for appattempt_1386194876944_0001_000002 exited with exitCode: 1 due to: Exception from container-launch: org.apache.hadoop.util.Shell$ExitCodeException: at org.apache.hadoop.util.Shell.runCommand(Shell.java:464) at org.apache.hadoop.util.Shell.run(Shell.java:379) at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:589) at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:195) at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:283) 相反,如果我以该用户身份登录,则不会发生错误并且MR作业将运行结束,而标记为“MRAppMaster”的Java图标会在Dock中弹出。 我已经将其缩小到ResourceManager,启动Java进程而不传递-Djava.awt.headless=true 。 在无头环境中发生这种情况时,JVM无权在根窗口中显示。 这已经出现在其他一些情况下,我已经纠正了每一个。 这不是权限问题(在别处建议的东西)或缺少目录。 但是我不知道如何影响最后一次未经许可访问根窗口的违规行为。 […]

如何在OS X上全局设置java系统属性?

短篇故事 我需要一种系统级方法来为所有java调用将java.awt.headless属性设置为true 。 也就是说,使用-Djava.awt.headless=true不是一个选项,因为java是从我无法访问的地方调用的(例如来自用Java / C /等编写的另一个工具)。 很长的故事 我正在使用一堆用Java编写的工具(特别是Adobe的Air ADT),这些工具依赖于AWT类。 当我在控制台上运行这些工具时,它们工作正常。 但是当我从SSH会话中运行它们时,它们会失败并出现java.lang.InternalError: Can’t connect to window server – not enough permissions 。 谷歌搜索我发现将java.awt.headless设置为true将解决问题。 它没有,这是因为ADT本身在没有 -Djava.awt.headless=true 情况下生成子Java进程。 是否有任何系统级方法来确保在调用Java时设置此属性? 也许一些系统awt属性文件或等价物? 最糟糕的情况我可以尝试使用shell脚本替换/usr/bin/java ,将此参数添加到”$@”但我希望避免这种情况。 (更新:为了确保我的理论是正确的,尝试这个shell脚本破解它确实解决了问题。只是希望有一个更清洁的解决方案)

如何使用Selenium连接到Chromium Headless

我想使用无头铬头进行selenium的自动化测试。 ( https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md ) 我确实已经在9222上运行了无头版本。所以如果我打开http://10.252.100.33:9222/json/我确实得到了 [ { “description”: “”, “devtoolsFrontendUrl”: “/devtools/inspector.html?ws=127.0.0.1:9223/devtools/page/0261be06-1271-485b-bdff-48e443de7a91”, “id”: “0261be06-1271-485b-bdff-48e443de7a91”, “title”: “The Chromium Projects”, “type”: “page”, “url”: “https://www.chromium.org/”, “webSocketDebuggerUrl”: “ws://127.0.0.1:9223/devtools/page/0261be06-1271-485b-bdff-48e443de7a91” } ] 作为下一步,我想将selenium连接到无头铬上。 但是,当我尝试 final DesiredCapabilities caps = DesiredCapabilities.chrome(); final WebDriver driver = new RemoteWebDriver(new URL(“http://localhost:9222/json”), caps); driver.get(“http://www.google.com”); 我确实得到以下注销 Jän 24, 2017 7:14:45 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFORMATION: Attempting bi-dialect session, assuming Postel’s […]

为自定义驱动程序创建GraphicsDevice

我正在研究一个在嵌入式系统中使用Java的项目。 我有屏幕和触摸输入的驱动程序,以及用于文本输入的虚拟键盘。 我的屏幕驱动程序有一个可以绘制的Graphics2D对象和一个用于更新的repaint(Rectangle)方法。 类似地,触摸驱动程序能够为侦听器生成MouseEvents 。 现在我正在直接绘制到屏幕上。 这很好,但我真正想要的是允许我的库的用户创建一个JFrame并使用普通的Swing元素。 但是,默认的GraphicsEnvironment是无头的,因为Java没有看到我的EInkDriver类或我的TouchDriver类。 我知道有一些方法可以调用组件的paint方法来获取图像; 但是当你绘制一个Container时会出现问题,我也想向用户提供一个GraphicsConfiguration这样他们就可以编写类似JFrame frame = new JFrame(getEInkGraphicsConfiguration()); 并继续进行,好像他们正在编写一个桌面Swing应用程序。 鉴于我已经拥有的这些function,我将如何创建一个允许我在项目中使用Swing的GraphicsDevice或GraphicsEnvironment ?

无头日食的config.ini设置

从这篇文章中 ,当我尝试执行无头eclipse代码时,我收到此错误消息。 java.lang.RuntimeException: Could not find framework at org.eclipse.equinox.launcher.Main.getBootPath(Main.java:978) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:557) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) 我用google搜索这个问题的答案: 启动Eclipse时“无法获取应用程序服务”错误 但是,我不确定如何放置config.ini以及如何放置正确的内容来删除错误消息。 这是我的目录结构,我在eclipse.ini中有Dosgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@文件。 如何设置eclipse.ini文件以及文件的位置? jar文件在plugins目录中, runme.sh有这个脚本: R2_HOME=. LIBS=plugins JARS=.:\ $LIBS/org.eclipse.core.contenttype_3.4.100.v20110423-0524.jar:\ $LIBS/org.eclipse.core.jobs_3.5.100.v20110404.jar:\ $LIBS/org.eclipse.core.runtime_3.7.0.v20110110.jar:\ $LIBS/org.eclipse.core.runtime.compatibility.auth_3.2.200.v20110110.jar:\ $LIBS/org.eclipse.equinox.common_3.6.0.v20110523.jar:\ $LIBS/org.eclipse.equinox.app_1.3.100.v20110321.jar:\ $LIBS/org.eclipse.equinox.launcher_1.2.0.v20110502.jar:\ $LIBS/org.eclipse.equinox.preferences_3.4.1.R37x_v20110725.jar:\ $LIBS/org.eclipse.core.variables_3.2.500.v20110928-1503.jar:\ $LIBS/org.eclipse.osgi.services_3.3.0.v20110513.jar:\ $LIBS/org.eclipse.osgi.util_3.2.200.v20110110:\ $LIBS/org.eclipse.osgi_3.7.2.v20120110-1415 java -cp $JARS org.eclipse.core.launcher.Main -application headlessHello2_1.0.0.201210101509.jar 添加 根据Paul的回答,我将config.ini文件复制到导出插件的目录中。 我还修改了脚本以使-application指向正确的id。 R2_HOME=. LIBS=plugins JARS=.:\ $LIBS/org.eclipse.core.contenttype_3.4.100.v20110423-0524.jar:\ … $LIBS/org.eclipse.osgi_3.7.2.v20120110-1415:\ headlessHello2_1.0.0.201210101509.jar java -cp […]

从HeadlessGraphicsEnvironment.getDefaultScreenDevice抛出的java.awt.HeadlessException

我需要在java服务器上进行一些图像处理(Debian with java version“1.6.0_12”),我从我的代码接收java.awt.HeadlessException: java.awt.HeadlessException at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:64) at WaxOn.getDefaultConfiguration(WaxOn.java:341) 即使java.awt.headless设置为true(这个代码打印明显如此): if (!java.awt.GraphicsEnvironment.isHeadless()) { logger.warn(“Headless mode is not enabled”); } else { logger.info(“Headless mode”); } 这是抛出exception的代码: public static GraphicsConfiguration getDefaultConfiguration() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); return gd.getDefaultConfiguration(); } 知道怎么解决这个问题吗?

无头地在Ubuntu Server上运行Chromedriver

我在Java(1.8)中使用Selenium和Chromedriver进行一些自动网络爬行: System.setProperty(“webdriver.chrome.driver”, “chromedriver.exe”); WebDriver driver = new ChromeDriver(); driver.get(“someurl.com”); 我正在尝试迁移到Ubuntu 16.04服务器。 在服务器上,我安装了Ubuntu chromedriver版本2.37,chrome版本65.根据chromedriver文档,这些版本是兼容的。 我已经更改了指定Ubuntu中chromedriver位置的代码: System.setProperty(“webdriver.chrome.driver”, “/usr/lib/local/chromedriver”); 在运行我的程序之前,我启动了xvfb: Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99 然后执行我的程序: java -jar myprogram.jar 以下内容将打印到控制台: Starting ChromeDriver 2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7) on port 10574 Only local connections are allowed. Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited […]