Issue running eclipse CDT build without GUI when not logged in (e.g. with jenkins or nohup)

58 Views Asked by At

When running a headless build for an eclipse CDT project (attempted through nohup, detached screen session, and jenkins) the build fails with the following error (shortened to first relevant line):

org.eclipse.ui.ide unable to load class org.eclipse.ui.internal.ide.misc.FileInfoAttributesMatcher
...

The build runs successfully if I am logged in normally, but fails if I'm logged out (which was the goal of nohup/screen/jenkins). It looks like the build is failing because it doesn't have an xserver, or can't access it. The command I'm running is similar to:

eclipse 
    --launcher.suppressErrors \
    -nosplash \
    -application org.eclipse.cdt.managedbuilder.core.headlessbuild \
    -data /path/to/workspace

Searching around I found a few things recommending I change cron settings for jenkins, or rework the eclipse projects, but the same project is built through jenkins in a different environment and by a user running the same build script. It's also odd that it fails the same way if I run it through nohup or a detached screen session, but only if I log off. Running through either and not logging off succeeds.

I am running in RHEL 8.

1

There are 1 best solutions below

0
Ian Ooi On

The answer was to use xvnc to create a virtual xsession. I ended up using something like the following in my jenkins configuration and build scripts:

vncserver :2
export DISPLAY=:2

# other build commands include eclipse

vncserver -kill :2

This should work for any situation without a GUI, e.g. jenkins, cron jobs, ssh without forwarding, nohup, detached screen sessions. It works by creating a virtual desktop which can "display" the windows, or in this case provide handles for X calls.