This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 197411

Summary: Should be able to log and run in headless mode
Product: platform Reporter: stoto79
Component: Module SystemAssignee: issues@platform <issues>
Status: RESOLVED FIXED    
Severity: normal CC: stoto79
Priority: P3    
Version: 7.0   
Hardware: PC   
OS: Other   
Issue Type: DEFECT Exception Reporter:

Description stoto79 2011-04-04 20:05:33 UTC
In JDeveloper, which is a product using netbinox, we need to be able to run our product in headless mode. In that case, should there be any errors at startup, we get 

    [exec] java.lang.ExceptionInInitializerError
    [exec]     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.getGTKStyleFactory(GTKLookAndFeel.java:1543)
    [exec]     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1507)
    [exec]     at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initialize(GTKLookAndFeel.java:1394)
    [exec]     at javax.swing.UIManager.setLookAndFeel(UIManager.java:513)
    [exec]     at javax.swing.UIManager.setLookAndFeel(UIManager.java:558)
    [exec]     at org.netbeans.core.startup.NbEvents$Notifier.run(NbEvents.java:348)
    [exec]     at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    [exec]     at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1957)
    [exec] Caused by: java.awt.HeadlessException
    [exec]     at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:64)
    [exec]     at com.sun.java.swing.plaf.gtk.PangoFonts.<clinit>(PangoFonts.java:43)
    [exec]     ... 8 more
    [exec] java.lang.ClassCastException: org.openide.filesystems.Repository$MainFS cannot be cast to org.netbeans.core.startup.layers.SystemFileSystem
    [exec]     at org.netbeans.core.startup.layers.ModuleLayeredFileSystem.getUserModuleLayer(ModuleLayeredFileSystem.java:231)
    [exec]     at org.netbeans.core.startup.NbInstaller.loadLayers(NbInstaller.java:535)
    [exec]     at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:331)
    [exec]     at org.netbeans.ModuleManager.enable(ModuleManager.java:993)
    [exec]     at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:318)
    [exec]     at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:254)
    [exec]     at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:286)
    [exec]     at org.netbeans.core.startup.Main.getModuleSystem(Main.java:172)
    [exec]     at org.netbeans.core.startup.Main.start(Main.java:308)
    [exec]     at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)
    [exec]     at java.lang.Thread.run(Thread.java:619)
Scanned 8844 files and directories in 568ms: 0 files added, 0 files removed, 0 directories added, 0 directories removed 

After some digging we saw that at line 348, org.netbeans.core.startup.NbEvents calls UIManager.setLookAndFeel().  This call should not be made when GraphicsEnvironment.isHeadless() returns true.  That seems to be the reason for the headless exception, and adding a check for isHeadless() might be all we need to do to fix it.
Comment 1 Jaroslav Tulach 2011-04-05 03:19:57 UTC
Netbinox runs in headless mode, unless dependencies of your plugins are broken. True, the error is slightly hidden, but if you fix your dependencies, then Netbinox starts ok in headless mode. I guess P3 is more appropriate priority.
Comment 2 stoto79 2011-04-05 07:46:49 UTC
Right, you only get this if there are warnings or errors on startup. Headless works fine otherwise. In our case, through the debugger, I saw it was trying to log text that went something like "WARNING: module oracle.ide cannot be loaded" but this bug was preventing it from surfacing to the user.
Comment 3 Jaroslav Tulach 2011-04-06 12:51:46 UTC
ergonomics#5ddeb01fe454
Comment 4 Quality Engineering 2011-04-07 08:48:15 UTC
Integrated into 'main-golden', will be available in build *201104070400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/5ddeb01fe454
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #197411: Check for headless mode and don't display splash or warnings