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 11459 - often get NullPointerExceptions when creating new EJB/Web/EJBmodule objects
Summary: often get NullPointerExceptions when creating new EJB/Web/EJBmodule objects
Status: CLOSED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: PC Windows 3.1/NT
: P2 blocker (vote)
Assignee: issues@javaee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-04-16 22:41 UTC by Roger Blumer
Modified: 2001-06-29 21:37 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stack trace of NullPointerException (10.02 KB, text/plain)
2001-04-16 22:41 UTC, Roger Blumer
Details
stacktrace when creating an Application object (3.35 KB, text/plain)
2001-04-16 22:43 UTC, Roger Blumer
Details
Patch to projects.jar (6.91 KB, application/octet-stream)
2001-07-20 20:37 UTC, akemr
Details
Stack trace after New -> WebModule - First attempt (4.66 KB, text/plain)
2001-07-20 20:37 UTC, akemr
Details
Stack trace after New -> WebModule - Second attempt (13.40 KB, text/plain)
2001-07-20 20:37 UTC, akemr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Blumer 2001-04-16 22:41:04 UTC
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)
Comment 1 Roger Blumer 2001-04-16 22:41:35 UTC
Created attachment 1129 [details]
stack trace of NullPointerException
Comment 2 Roger Blumer 2001-04-16 22:43:40 UTC
Created attachment 1130 [details]
stacktrace when creating an Application object
Comment 3 David Strupl 2001-04-17 14:24:27 UTC
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;
    }
}
Comment 4 akemr 2001-04-17 15:22:05 UTC
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!
Comment 5 akemr 2001-04-17 15:23:01 UTC
Created attachment 1138 [details]
Patch to projects.jar
Comment 6 Roger Blumer 2001-04-17 16:38:53 UTC
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.

  
Comment 7 Roger Blumer 2001-04-17 16:50:45 UTC
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.)
Comment 8 Roger Blumer 2001-04-17 18:08:57 UTC
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.
Comment 9 akemr 2001-04-23 15:39:03 UTC
Created attachment 1212 [details]
Stack trace after New -> WebModule - First attempt
Comment 10 akemr 2001-04-23 15:39:41 UTC
Created attachment 1213 [details]
Stack trace after New -> WebModule - Second attempt
Comment 11 akemr 2001-04-23 15:48:34 UTC
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
Comment 12 _ gfink 2001-04-23 22:41:52 UTC
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.
Comment 13 Jan Chalupa 2001-05-06 15:52:09 UTC
Target milestone -> 3.2
Comment 14 _ hlu 2001-06-29 21:37:14 UTC
Test it with build ee010628 and the bug is gone.