zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Eclipse UI测试在Redhat Jenkins服务器上使用gtk_init_check()失败

2023-04-18 13:03:13 时间

当通过Jenkins在Redhat服务器(6.7)上对Eclipse运行Tycho UI测试时,发生下面的异常。我知道一个图形子系统必须安装并运行,但是我的设置似乎有些不妥。我已经通过“yum groupinstall Desktop”安装了GTK。Eclipse UI测试在Redhat Jenkins服务器上使用gtk_init_check()失败

org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed] 
    at org.eclipse.swt.SWT.error(SWT.java:4517) 
    at org.eclipse.swt.widgets.Display.createDisplay(Display.java:908) 
    at org.eclipse.swt.widgets.Display.create(Display.java:892) 
    at org.eclipse.swt.graphics.Device.<init>(Device.java:156) 
    at org.eclipse.swt.widgets.Display.<init>(Display.java:512) 
    at org.eclipse.swt.widgets.Display.<init>(Display.java:503) 
    at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:790) 
    at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:162) 
    at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:169) 
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:111) 
    at org.eclipse.tycho.surefire.osgibooter.UITestApplication.runApplication(UITestApplication.java:31) 
    at org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication.run(AbstractUITestApplication.java:115) 
    at org.eclipse.tycho.surefire.osgibooter.UITestApplication.start(UITestApplication.java:37) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488) 

richardb

回答

虚拟桌面必须运行。对此可以使用Xvfb,如http://www-01.ibm.com/support/docview.wss?uid=swg21421214所述。在Redhat上可以使用:

yum install xorg-x11-server-Xvfb 
Xvfb :5 -screen 0 1280x1024x8 -fbdir /tmp & 
export DISPLAY=:5 

显示的数字可以任意选择。在Jenkins作业中,环境变量也必须设置(通过set-env插件)。

为了在所有作业中启用这个描述如下的脚本:https://superuser.com/questions/319040/proper-way-to-start-xvfb-on-startup-on-centos应该使用chkconfig进行设置。最后,环境变量DISPLAY应该可通过添加一个shell脚本来/etc/profile.d/在其中包含唯一的行:

export DISPLAY=:5 

试验期间在我设置的默认运行级别5/etc/inittab中/但我没有进一步研究这是否是绝对必要的。

richardb

Eclipse UI测试在Redhat Jenkins服务器上使用gtk_init_check()失败