glassfish
  1. glassfish
  2. GLASSFISH-3768

poorman's installer incorrectly set laf on the main thread, causing NPE

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 9.1pe
    • Fix Version/s: not determined
    • Component/s: installation
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      3,768
    • Status Whiteboard:
      Hide

      as91ur1-na

      Show
      as91ur1-na

      Description

      A user reported this problem on glassfish Chinese forum here:
      http://gceclub.sun.com.cn/NASApp/sme/jive/thread.jsp?forum=22&thread=46763

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at
      com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
      at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
      at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
      at
      com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at
      java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at
      java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
      Exception in thread "main" java.lang.NullPointerException
      at
      javax.swing.plaf.synth.SynthLookAndFeel$AATextListener.propertyChange(SynthLookAndFeel.java:793)
      at
      java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
      at
      java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:347)
      at
      java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
      at java.awt.Toolkit.setDesktopProperty(Toolkit.java:1784)
      at sun.awt.SunToolkit.fireDesktopFontPropertyChanges(SunToolkit.java:1698)
      at sun.awt.SunToolkit.setAAFontSettingsCondition(SunToolkit.java:1743)
      at sun.swing.SwingUtilities2$AATextInfo.getAATextInfo(SwingUtilities2.java:119)
      at
      com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initComponentDefaults(GTKLookAndFeel.java:1258)
      at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.getDefaults(GTKLookAndFeel.java:294)
      at javax.swing.UIManager.setLookAndFeel(UIManager.java:537)
      at javax.swing.UIManager.setLookAndFeel(UIManager.java:581)
      at org.jvnet.poormans_installer.Main.setUILookAndFeel(Main.java:95)
      at org.jvnet.poormans_installer.Main.main(Main.java:50)
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at
      com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
      at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
      at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
      at
      com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at
      java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at
      java.awt.EventDispatchThread.run(EventDispatchThread.java:121

      The user was trying to install glassfish on Debian with JDK 6, running java -jar
      glassfishv2.jar

      It appears that glassfish's poorman's installer incorrectly sets the laf on the
      main thread, whereas it should be set on the EDT (event dispatching thread). A
      google search also shows a related JDK 6 bug:
      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6585553 (NPE in
      GTKLookAndFeel.initSystemColorDefaults() on mustang when remote X11 displaying.).

      Can we fix our installer main class to correctly set laf?

      The poorman's installer main class is below, where you can see how the laf is
      set, incorrectly, on the main thread.

      public class Main
      {

      public Main()
      {
      }

      public static void main(String args[])
      throws IOException
      {
      Reader in = new
      InputStreamReader((org.jvnet.poormans_installer.Main.class).getResourceAsStream("/license.txt"));
      boolean checked = false;
      boolean accepted;
      if(args.length > 0 && args[0].equals("-console"))
      accepted = doConsole(in);
      else
      try

      { setUILookAndFeel(); LicenseForm form = new LicenseForm(in); form.show(); accepted = form.isAccepted(); checked = form.isChecked(); }

      catch(InternalError e)

      { accepted = doConsole(in); checked = false; }
      catch(UnsupportedOperationException e)
      { accepted = doConsole(in); checked = false; }

      if(accepted)
      install();
      if(checked)
      createPropertyFile();
      System.exit(accepted ? 0 : 1);
      }

      private static boolean doConsole(Reader in)
      throws IOException

      { ConsoleForm form = new ConsoleForm(in); form.show(); boolean accepted = form.isAccepted(); return accepted; }

      private static void setUILookAndFeel()
      {
      String nativeLF = UIManager.getSystemLookAndFeelClassName();
      try

      { UIManager.setLookAndFeel(nativeLF); }

      catch(InstantiationException e) { }
      catch(ClassNotFoundException e) { }
      catch(UnsupportedLookAndFeelException e) { }
      catch(IllegalAccessException e) { }
      }

      private static void install()
      throws IOException
      {
      ZipInputStream zip = new
      ZipInputStream((org.jvnet.poormans_installer.Main.class).getResourceAsStream("/package.zip"));
      do
      {
      ZipEntry e;
      if((e = zip.getNextEntry()) == null)
      break;
      File name = new File(e.getName());
      System.out.println(name);
      if(e.isDirectory())

      { name.mkdirs(); }

      else

      { File parent = name.getParentFile(); if(parent != null && !parent.exists()) parent.mkdirs(); if(!name.exists()) copyStream(zip, new FileOutputStream(name)); }

      } while(true);
      zip.close();
      System.out.println("installation complete");
      }

      private static void createPropertyFile()
      {
      try

      { File propertyFile = new File("input.properties"); FileOutputStream out = new FileOutputStream(propertyFile); String content = "checkbox.value=true"; out.write(content.getBytes()); out.close(); }

      catch(Exception e) { }
      }

      public static void copyStream(InputStream in, OutputStream out)
      throws IOException

      { byte buf[] = new byte[256]; int len; while((len = in.read(buf)) >= 0) out.write(buf, 0, len); out.close(); }

      }

      One possible solution is something like this:

      public static void doGUI()

      { //set laf here... }

      public static void main(String[] args) {
      //Schedule a job for the event-dispatching thread:
      //creating and showing this application's GUI.
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
      public void run()

      { doGUI(); }

      });
      }

        Activity

        Cheng Fang created issue -
        Hide
        Cheng Fang added a comment -

        changed release version to 9.1pe and target release to 9.1.1

        Show
        Cheng Fang added a comment - changed release version to 9.1pe and target release to 9.1.1
        Hide
        gfbugbridge added a comment -

        <BT6616579>

        Show
        gfbugbridge added a comment - <BT6616579>
        Hide
        kumara added a comment -

        snjezana->kohsuke for evaluation.

        Show
        kumara added a comment - snjezana->kohsuke for evaluation.
        Hide
        basler added a comment -

        This change doesn't pertain to 9.1ur1

        Show
        basler added a comment - This change doesn't pertain to 9.1ur1
        Hide
        kohsuke added a comment -

        Fixed in the poorman's installer repository. Needs to find out who creates GF
        installer.

        Show
        kohsuke added a comment - Fixed in the poorman's installer repository. Needs to find out who creates GF installer.
        Hide
        sanandal added a comment -

        "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1
        release whose primary release driver is SailFin.
        This issue will be scrubbed after this release and will be given the right
        priority for the next release."

        Show
        sanandal added a comment - "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1 release whose primary release driver is SailFin. This issue will be scrubbed after this release and will be given the right priority for the next release."
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 3768 35372
        Hide
        Tom Mueller added a comment -

        Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

        Show
        Tom Mueller added a comment - Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.
        Tom Mueller made changes -
        Fix Version/s not determined [ 11149 ]
        Fix Version/s 9.1.1 [ 10973 ]

          People

          • Assignee:
            kohsuke
            Reporter:
            Cheng Fang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: