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.
Creating new objects often causes NullPointerExceptions in the Project code, usually isAccessibleFromFolder (see below). This has happened when creating Web/Ejb Module and Application objects. The problem line (from the trace) is DataObject dobjs[] = folder.getChildren(); for(int i = 0; i < dobjs.length; i++) { FileObject fo = getOriginal(dobj).getPrimaryFile(), ==> ff = getOriginal(dobjs[i]).getPrimaryFile(); I'm assuming the problem is that dobjs is null, so maybe this is a timing problem with getChildren? Otherwise maybe getChildren is returning nulls within its returned array? Thu Apr 12 12:31:53 PDT 2001: java.lang.NullPointerException: null java.lang.NullPointerException at org.netbeans.modules.projects.ProjectDataObject.isAccessibleFromFolder(ProjectDa taObject.java:284) at org.netbeans.modules.projects.ProjectDataObject.isAccessibleFromFolder(ProjectDa taObject.java:271) at org.netbeans.modules.projects.ProjectDataLoader$Performer.run(ProjectDataLoader. java:129) at org.openide.util.Task.run(Task.java:124) [catch] at org.openide.util.RequestProcessor$ProcessorThread.run(RequestProcessor.java:622)
Created attachment 1129 [details] stack trace of NullPointerException
Created attachment 1130 [details] stacktrace when creating an Application object
This code in projects/src/org/netbeans/modules/projects/ProjectDataObject seems to be ok: /** Test whether the object is accessible from folder. */ public static boolean isAccessibleFromFolder(DataFolder folder, DataObject dobj) { // get all objects under FilesFolder // dobj must be either the non-folder object or the folder should be // somewhere on path to the root DataObject dobjs[] = folder.getChildren(); for(int i = 0; i < dobjs.length; i++) { FileObject fo = getOriginal(dobj).getPrimaryFile(), ff = getOriginal(dobjs[i]).getPrimaryFile(); while (fo != null) { if (fo.equals(ff)) return true; fo = fo.getParent(); } } return false; } /** De-shadow the object. * @return return the original if the obj is DataShadow, otherwise return obj */ public static DataObject getOriginal(DataObject obj) { while (obj instanceof DataShadow) obj = ((DataShadow) obj).getOriginal(); return obj; } }
I cannot reproduce this bug. Also I don't know what object is null. So, could you please use attached patch (copy it to modules/projects.jar) to reproduce this bug? Patch prints to std out line(lines) beginning ProjectDataObject: I fthis bug occurs, could you please attach these std out? Maybe it will be nice to add steps to reproduce. Thanks a lot!
Created attachment 1138 [details] Patch to projects.jar
Steps to reproduce: use Pilsen EE build create a new application: New->J2EE->Appication enter a name for the application hit Finish button of the wizard exception occurs; application is created & works fine, though. When it happens, it seems to happen for every creation after that, in the same session.
I was able to reproduce this again, but only after unmounting a web module in the same session. There was a bug 11325 about that hitting non-thread-safe code (http://www.netbeans.org/issues/show_bug.cgi?id=11325), so maybe this problem is a side-effect of that. (By the way, I wasn't able to run using the patched projects.jar; the IDE hung with an NPE exception in org.apache.xerces.framework.XMLParser.parse(XMLParser.java:969); I'll send that separately, since I don't want to clutter this bug with an unrelated stack trace.)
I've verified that this is a side-effect of bug 11325. The exception occurs even in later sessions after unmounting a web module. But, under the debugger, I found that getOriginal(dobjs[i]) is returning null, and dobjs[i] is pointing to a webAppObject for a directory that I unmounted in a previous session! So the project's state is inconsistent.
Created attachment 1212 [details] Stack trace after New -> WebModule - First attempt
Created attachment 1213 [details] Stack trace after New -> WebModule - Second attempt
Problem is probably in Web module. WebAppLoader inherits from DataShadow, and in handleFindDataObject incorrectly handles exceptions. 1. run IDE with netbeans.debug.exceptions 2. In some clear subdirectory of some filesystem create New -> JSP&Servlet -> WebModule Exception is attached - trace1.txt 3. No WebModule mounted. 4. Again try 2. Exception is attached - trace2.txt
WebAppObject subclasses DataShadow; since the Sandwich change subclassing DataShadow is impossible to do correctly (since you must privately implement BrokenDataShadow and associated classes/methods). To fix, I've copied BrokenDataShadow, ShadowChangeAdapter, and other methods to the web module. Obviously this should be revisited in NB 3.3.
Target milestone -> 3.2
Test it with build ee010628 and the bug is gone.