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 209616 - Exception on the first run of a Java application
Summary: Exception on the first run of a Java application
Status: RESOLVED FIXED
Alias: None
Product: ide
Classification: Unclassified
Component: Extbrowser (show other bugs)
Version: 7.2
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Denis Anisimov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-15 13:24 UTC by Petr Jiricka
Modified: 2012-09-03 12:55 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Exception in output window (2.62 KB, text/plain)
2012-03-15 13:24 UTC, Petr Jiricka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2012-03-15 13:24:32 UTC
Created attachment 116764 [details]
Exception in output window

Easel build #134, Mac OS X 10.7.3, JDK "1.6.0_29"

When running a Java web application for the first time, I am getting the attached exception in the output window. My web browser in IDE options is set to System Default, and my system default browser is Chrome.
Comment 1 Petr Jiricka 2012-03-15 13:26:34 UTC
The workaround is to go system options dialog and cancel it - after that the browser is called.
Comment 2 Petr Jiricka 2012-03-15 17:30:24 UTC
After debugging this, what happens is the following:
- In the getFactories method, getConfigFolder returns Services/Browsers, i.e. non-null
- It has 10 children as expected
- When iterating over the children, HtmlBrowser.Factory fact is correctly initialized
- BUT then, the lookupItem method returns null

BTW, why is this call in every iteration of the loop?
Lookup.getDefault ().lookupAll(HtmlBrowser.Factory.class);
Wouldn't it be enough to do it just once?

Making the following change as suggested by Denis off-line, helps, and fixes the problem:

--- a/web.browser.api/src/org/netbeans/modules/web/browser/api/WebBrowsers.java
+++ b/web.browser.api/src/org/netbeans/modules/web/browser/api/WebBrowsers.java
@@ -185,6 +185,7 @@
     }
     
     private List<WebBrowserFactoryDescriptor> getFactories() {
+        IDESettings.getWWWBrowser();
         List<WebBrowserFactoryDescriptor> browsers = new ArrayList<WebBrowserFactoryDescriptor>();
         FileObject servicesBrowsers = getConfigFolder();
         if (servicesBrowsers == null) {
Comment 3 David Konecny 2012-03-16 00:57:28 UTC
Sorry, in the meantime I fixed it differently as suddenly I bumped into the same problem. Denis's suggestion would work as well. My fixes forces items out of the lookup - there must be some optimalization in lookup to not create items unless somebody does something with them.
84d36ee633ae
Comment 4 Quality Engineering 2012-09-03 12:55:57 UTC
Integrated into 'main-golden', will be available in build *201209031048* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/84d36ee633ae
User: David Konecny <dkonecny@netbeans.org>
Log: #209616 - Exception on the first run of a Java application