groovy
  1. groovy
  2. GROOVY-2870

Abnormal JVM exit on wrong DISPLAY setting

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: UNRESOLVED
    • Affects Version/s: 1.5.6
    • Fix Version/s: None
    • Component/s: Groovysh
    • Labels:
      None
    • Environment:
      SuSE 9.1
    • Number of attachments :
      0

      Description

      An illegal display settng causes a stack trace because the AWT environment cannot be openend, In addition, the terminal stays in raw, non-echo mode, forcing you to blindly type "stty sane" to get it back into a usable state. See the following session log...

      Solution: catch the "java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment" and print a nice error message, and in a finally reset the terminal (or do it in the groovysh wrapper script if that is not possible due to the abnormal JVM exit).

      — Possible shell snippet —
      if $RAW; then
      SAVED_MODES=$(stty -g)
      trap "stty $SAVED_MODES" EXIT SIGHUP SIGINT SIGQUIT SIGABRT SIGSEGV SIGTERM
      stty raw -echo ignbrk brkint inlcr icrnl opost isig
      fi

      1. start in subshell so stty reset is ensured
        ( startGroovy @project.package@.Console "$@" )

      if $RAW; then
      stty $SAVED_MODES
      fi

      — LOG —
      thirdparty/groovy > groovysh
      Groovy Shell (1.5.6, JVM: 10.0-b19)
      Type 'help' or '\h' for help.
      ----------------------------------------------------------------------------------------------------
      groovy:000>
      thirdparty/groovy > export DISPLAY=BUGGY
      thirdparty/groovy > groovysh
      java.lang.reflect.InvocationTargetException
      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.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:101)
      at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
      Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
      at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:89)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at java.awt.Toolkit$2.run(Toolkit.java:836)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:828)
      at sun.swing.SwingUtilities2$AATextInfo.getAATextInfo(SwingUtilities2.java:120)
      at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:1556)
      at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:130)
      at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1591)
      at javax.swing.UIManager.setLookAndFeel(UIManager.java:537)
      at javax.swing.UIManager.setLookAndFeel(UIManager.java:577)
      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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1105)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:749)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
      at org.codehaus.groovy.tools.shell.Main.main(Main.groovy:116)
      ... 6 more

      java.lang.IllegalStateException: Shutdown in progress
      at java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:39)
      at java.lang.Runtime.addShutdownHook(Runtime.java:192)
      at jline.UnixTerminal.initializeTerminal(UnixTerminal.java:97)
      at jline.Terminal.setupTerminal(Terminal.java:75)
      at jline.Terminal.getTerminal(Terminal.java:26)
      at org.codehaus.groovy.tools.shell.util.ANSI.detect(ANSI.java:48)
      at org.codehaus.groovy.tools.shell.util.ANSI.isDetected(ANSI.java:59)
      at org.codehaus.groovy.tools.shell.util.ANSI.isEnabled(ANSI.java:70)
      at org.codehaus.groovy.tools.shell.util.ANSI$Buffer.attrib(ANSI.java:225)
      at org.codehaus.groovy.tools.shell.util.ANSI$Renderer.evaluate(ANSI.java:313)
      at org.codehaus.groovy.tools.shell.util.ANSI$Renderer.render(ANSI.java:289)
      at org.codehaus.groovy.tools.shell.util.ANSI$RenderWriter.write(ANSI.java:378)
      at java.io.PrintWriter.print(PrintWriter.java:559)
      at java.io.PrintWriter.println(PrintWriter.java:695)
      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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
      at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:766)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:754)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
      at org.codehaus.groovy.tools.shell.Main$_main_closure2.doCall(Main.groovy:109)
      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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:248)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
      at org.codehaus.groovy.tools.shell.Main$_main_closure2.doCall(Main.groovy)
      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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:248)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
      at groovy.lang.Closure.call(Closure.java:292)
      at groovy.lang.Closure.call(Closure.java:287)
      at groovy.lang.Closure.run(Closure.java:368)
      at java.lang.Thread.run(Thread.java:619)
      WARNING: Abnormal JVM shutdown detected
      thirdparty/groovy > *** ECHOLESS CONSOLE HERE ***

        Activity

        Hide
        blackdrag blackdrag added a comment -

        so what you suggest is not to try to find a fix for this AWT error, but to add a trick to reset the console after a groovy program was run... right?

        Show
        blackdrag blackdrag added a comment - so what you suggest is not to try to find a fix for this AWT error, but to add a trick to reset the console after a groovy program was run... right?
        Hide
        Jürgen Hermann added a comment -

        Don't know whether you can find out beforehand if DISPLAY contains a bad value or not, or if it's only possible after the fact.

        What should be avoided, especially for novice users, is the not-so-nice error message (stacktrace) without a hint to the probable cause, and the "your terminal appears to be dead now" effect.

        Also, very likely ANY other cause for an Abnormal JVM shutdown will show this effect (leaving the console in limbo), not just this AWT error.

        Show
        Jürgen Hermann added a comment - Don't know whether you can find out beforehand if DISPLAY contains a bad value or not, or if it's only possible after the fact. What should be avoided, especially for novice users, is the not-so-nice error message (stacktrace) without a hint to the probable cause, and the "your terminal appears to be dead now" effect. Also, very likely ANY other cause for an Abnormal JVM shutdown will show this effect (leaving the console in limbo), not just this AWT error.
        Hide
        Pascal Schumacher added a comment -

        As this issue has received no new comments in over five years I'm closing it. If it is still relevant please reopen. Thanks!

        Show
        Pascal Schumacher added a comment - As this issue has received no new comments in over five years I'm closing it. If it is still relevant please reopen. Thanks!

          People

          • Assignee:
            Unassigned
            Reporter:
            Jürgen Hermann
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: