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.
I finally managed to reproduce the symptoms of issue #80367. All you need to do is customize the default platform (e.g. add Javadoc); shut down; delete contents of $userdir/config/Services/Platforms/org-netbeans-api-java-Platform/default_platform.xml while leaving an empty file there; and restart. I speculate that the root cause is some IOException (or RuntimeException) being thrown from PlatformConvertor.W.write. If this happens, part of the file will be written but will leave malformed XML behind. The exception should be printed, but it would be in a previous IDE session and so we might not see it. Anyway, it is clear that if write(...) does fail, we should not corrupt an existing, valid platform definition! And even if a definition is corrupt, the fix mentioned in issue #80367 is not adequate: while the NPE is no longer thrown during startup, there is still no default platform (so most projects will be unusable) and you cannot just create a platform named default_platform in the new platform wizard as a workaround (since it says the file already exists). So I think for this to be really fixed we also need to do these things: 1. PlatformConvertor should write to a buffer first, and only then write the buffer to the file, to minimize the chance of producing a broken file due to a halfway exception. 2. DefaultJavaPlatformProvider.getInstalledPlatforms should recover somehow from files w/o InstanceCookie. Could just delete them but this is not helpful for the default platform. Alternatively, J2SEPlatformModule.updateBuildProperties could check for installedPlatforms.length == 0; in this case, copy resources/templates/defaultPlatform.xml into Services/Platforms/org-netbeans-api-java-Platform/default_platform.xml in order to reset it to default. (In trunk you can instead use the API proposed in issue #79722.)
If it can be fixed, should probably be put in 5.5 too.
*** Issue 79650 has been marked as a duplicate of this issue. ***
So after some searching, found some more reported bugs. To the list of things that should be fixed, I would now add 3. W.write should not print out lines of raw XML, as this is very dangerous. (Will quietly write malformed XML if some metachars need to be escaped.) Should create a DOM tree and use XMLUtil.write instead. Given the number of duplicates of the dependent issues (and unreported incidents, on feedback aliases, uninstall comments, ...) this group of bugs seems to be a blocker for many people trying to use NB 5.0. IMHO it would deserve a hotfix, although I suspect anyone encountering this bug would have uninstalled NB already since it would be unusable.
The root case of the empty default_platform.xml is NPE from the PlatformConvertor.shouldWriteSources() which is fixed in the dev and the NB 5.5 (http://www.netbeans.org/issues/show_bug.cgi?id=72127). Creating the document in the buffer using DOM and storing it when it is created is a good idea, I will change it in this way. The work around for this issue is to delete the corrupted default_platform.xml from the user dir.
Fixed in trunk. PlatformConvertor uses DOM to store platform. The platform is firstly stored into memory and after it the buffer is written onto the disk. J2SEPlatformModule recovers broken default_platform. I am going to integrate the PlatformConvertor changes also into the 5.5 Checking in src/org/netbeans/modules/java/j2seplatform/J2SEPlatformModule.java; /cvs/java/j2seplatform/src/org/netbeans/modules/java/j2seplatform/J2SEPlatformModule.java,v <-- J2SEPlatformModule.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/netbeans/modules/java/j2seplatform/platformdefinition/PlatformConvertor.java; /cvs/java/j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/PlatformConvertor.java,v <-- PlatformConvertor.java new revision: 1.18; previous revision: 1.17 done
Note that the patch to J2SEPlatformModule.java will only work in trunk (after issue #79722 is implemented), not in release55. So don't bother merging that part. You may still need to check for non-XML-encodable property values in writeProperties. (Really I've never understood why we write every Java system property to these files to begin with, when we only ever read one or two, but maybe you have some reason.)
I will add an XMLUtil.toAttributeValue() to check if the property name and value is encodable. There are several modules which need more properties (profiler uses sun.arch.data.model). It is hard to say which properties to store.
Checking in src/org/netbeans/modules/java/j2seplatform/platformdefinition/PlatformConvertor.java; /cvs/java/j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/PlatformConvertor.java,v <-- PlatformConvertor.java new revision: 1.19; previous revision: 1.18 done
Integrated into 5.5 Checking in src/org/netbeans/modules/java/j2seplatform/platformdefinition/PlatformConvertor.java; /cvs/java/j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/PlatformConvertor.java,v <-- PlatformConvertor.java new revision: 1.13.22.1.2.3; previous revision: 1.13.22.1.2.2 done
*** Issue 87041 has been marked as a duplicate of this issue. ***
*** Issue 83007 has been marked as a duplicate of this issue. ***
*** Issue 89786 has been marked as a duplicate of this issue. ***