28

I was trying to open eclipse in my ubuntu VM with the below commmand.. And as soon as I do that, I always get the below exception -

ubuntu@username-dyn-vm1-48493:~$ eclipse
Eclipse:
An error has occurred. See the log file
/home/ubuntu/.eclipse/org.eclipse.platform_3.8_155965261/configuration/1381367113197.log.

so when I went to that particular log file, this is what I can see in the log -

ubuntu@username-dyn-vm1-48493:~$ more /home/ubuntu/.eclipse/org.eclipse.platform_3.8_155965261/configuration/1381367113197.log
!SESSION 2013-10-10 01:05:13.088 -----------------------------------------------
eclipse.buildId=debbuild
java.version=1.7.0_25
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64

!ENTRY org.eclipse.osgi 4 0 2013-10-10 01:05:17.555
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
        at org.eclipse.swt.SWT.error(SWT.java:4387)
        at org.eclipse.swt.widgets.Display.createDisplay(Display.java:914)
        at org.eclipse.swt.widgets.Display.create(Display.java:900)
        at org.eclipse.swt.graphics.Device.<init>(Device.java:156)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:498)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:489)
        at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:716)
        at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161)
        at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:154)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:96)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

Does anyone know what wrong has happened? Or what I am supposed to do to fix this issue? Thanks..

Update:-

Version details below -

ubuntu@username-dyn-vm1-48493:~$ dpkg -l libgtk[0-9]* | grep ^i
ii  libgtk2.0-0:amd64                   2.24.17-0ubuntu2                    amd64        GTK+ graphical user interface library
ii  libgtk2.0-bin                       2.24.17-0ubuntu2                    amd64        programs for the GTK+ graphical user interface library
ii  libgtk2.0-common                    2.24.17-0ubuntu2                    all          common files for the GTK+ graphical user interface library
2
  • weirdly enough I had a similiar problem trying to run dbeaver. I had to exit tmux first for it to work properly. Odd
    – matchew
    Nov 19, 2019 at 19:17
  • Note: I got this issue with pentaho.I wasn't sshed into another machine but was switching user by sudo su username. Instead when i did ssh -X username@localhost, things worked
    – taari
    Jun 1, 2021 at 15:45

6 Answers 6

11

This is also the error you get if you try to start Eclipse over ssh without forwarding X access. Ie, you forgot to run ssh -X user@host or forgot to include ForwardX11 yes in your ~/.ssh/config entry for the server.

I'm adding this answer for anyone who may stumble upon this question from a Google search even though technically, OP is asking about a VM case.

4
  • 1
    @isakbob Thank you, this solved my issue. Couldn't find the answer anywhere else. Might want to post it as an answer.
    – Mdev
    Nov 20, 2019 at 21:25
  • @Matthew I don't think my comment warrants another answer. I just edited this answer to include my comment.
    – isakbob
    Nov 20, 2019 at 22:21
  • @isakbob doesnt look like it's there anymore
    – Mdev
    Dec 11, 2019 at 18:34
  • @Matthew ¯\_(ツ)_/¯ guess it's assumed to be common sense then.
    – isakbob
    Dec 11, 2019 at 18:58
6

I think this is a problem with gtk. Check what version is installed.

dpkg -l libgtk[0-9]* | grep ^i

If it's not installed or is the incorrect version then do a sudo apt-get install gtk or do an sudo apt-get update.

EDIT

The problem was that SSH was using SSH to remote into a Linux VM and didn't have an X-Server set up on Windows and didn't have X11 forwarding enabled. After getting that straightened out the OP shouldn't have any issues running Eclipse.

7
  • I updated my question with the actual version information.. Let me know if still I need to do update?
    – SSH
    Oct 10, 2013 at 19:06
  • Well there is a version 3.8 for gtk out there so it couldn't hurt to update to the latest version.
    – Jeight
    Oct 10, 2013 at 19:09
  • 3
    I see.. But when I updated it this is what I got - sudo apt-get install gtk Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package gtk . It's not able to locate the package gtk somehow.. Any idea?
    – SSH
    Oct 10, 2013 at 19:09
  • What do you get when you do a sudo apt-cache search gtk?
    – Jeight
    Oct 10, 2013 at 19:11
  • It did lot of things.. And whole bunch of things got printed out on my screen.. Not sure what you might be interested in?
    – SSH
    Oct 10, 2013 at 19:12
6

In addition, this may also be caused by the application not having the correct authorization to display to the remote X server. This typically happens when you log into the ssh session as one user and execute a command as another user to lauch a GUI application. For example when you log into the remote server and execute a sudo command. To resolve this issue, you will need to obtain the magic cookie of the user logging in and import the cookie for the user running the command.

As the user logging into the server which has authority to display to X, run:

xauth extract cookie_file $DISPLAY

Then as the user trying to run the gui: xauth merge cookie_file

Once the cookie is imported into the user's .Xauthority file, you should be able to execute the GUI.

2
  • 1
    There is also possible, that host just doe not have display at all. In this case you can install Xvfb, and create virtual frame buffer with commands: Xvfb :1 -ac -screen 0 1024x768x8 & export DISPLAY=:1 source
    – Staszek
    Nov 28, 2017 at 8:36
  • @Staszek: Thanks, thanks, thanks! May 14, 2021 at 10:22
5

I ran into a similar problem while installing IBM Installation Manager (IBMIM) on CentOS 6.x and worked around the issue by installing several packages which were the cause of this identical error:

$ sudo /opt/IBM/InstallationManager/eclipse/IBMIM \
       -record /root/was8nd_v85_install.xml \
       -skipInstall /tmp/was8nd

00:00.46 ERROR [main] org.eclipse.equinox.log.internal.ExtendedLogReaderServiceFactory safeLogged
  Application error
  org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
  org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
    at org.eclipse.swt.SWT.error(SWT.java:4387)
    at org.eclipse.swt.widgets.Display.createDisplay(Display.java:913)
    at org.eclipse.swt.widgets.Display.create(Display.java:899)
    at org.eclipse.swt.graphics.Device.<init>(Device.java:156)
    ...
IBMIM:
An error has occurred. See the log file
/opt/IBM/InstallationManager/eclipse/configuration/1457978953529.log.

Solution part 1 - missing packages

$ sudo yum install \
   gtk2            \
   libXtst         \
   gnome-desktop   \
   xorg-x11-xauth  \
   dejavu-lgc-sans-fonts 

Something similar to this could've been done on Ubuntu as well.

Solution part 2 - xauth

The other issue that'll arise is you're attempting to run the IBMIM installer (Eclipse based) as the root user via sudo. When you do this you'll get the above Application error from the installer:

00:00.46 ERROR [main] org.eclipse.equinox.log.internal.ExtendedLogReaderServiceFactory safeLogged
  Application error
  org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
  org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]

To work around this you'll need to use xauth add to add the initial user you logged in as to root's $HOME/.Xauthority file.

As user1:

$ xauth list
ip-10-10-10-10.us-west-1.compute.internal/unix:10  MIT-MAGIC-COOKIE-1  6902e8c245a01ca50XXXXXXXXXXXXXXXX

Then as root:

$ xauth add ip-10-10-10-10.us-west-1.compute.internal/unix:10  MIT-MAGIC-COOKIE-1  6902e8c245a01ca50XXXXXXXXXXXXXXXX
xauth:  creating new authority file /root/.Xauthority

$ xauth list
ip-10-10-10-10.us-west-1.compute.internal/unix:10  MIT-MAGIC-COOKIE-1  6902e8c245a01ca50XXXXXXXXXXXXXXXX

References

0

If you are running on a linux with Gnome:

Start a Gnome with an Xorg session:

After clicking your username in GDM (the greeter/login manager), click your username and before entering the password, click the little gear and select Gnome with Xorg, then enter your password

-1

After disabling IPV6 on the remote machine I received the message org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed] when using command ssh -X ub-dev /opt/eclipse/eclipse. To fix on Ubuntu 14.04 I added line AddressFamily inet to file /etc/ssh/sshd_config and restarted ssh sudo service ssh restart.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .