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 54060 - [VCS] NPE when add bean to project
Summary: [VCS] NPE when add bean to project
Status: CLOSED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: vcscore (show other bugs)
Version: 4.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on: 54421
Blocks:
  Show dependency tree
 
Reported: 2005-01-27 07:28 UTC by Petr Blaha
Modified: 2006-03-24 13:13 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stack trace (17.73 KB, text/plain)
2005-01-27 07:29 UTC, Petr Blaha
Details
The log with calls to isParentOf(). (359.78 KB, text/plain)
2005-02-08 10:29 UTC, Martin Entlicher
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Blaha 2005-01-27 07:28:32 UTC
[Build 20050125]
Steps:
1) create J2EE application with EJB and web module
2) add the project to CVS
3) go to project tab and clcik on project tab,
invoke New | Session Bean
Get NPE
Comment 1 Petr Blaha 2005-01-27 07:29:20 UTC
Created attachment 19992 [details]
stack trace
Comment 2 Martin Adamek 2005-01-31 12:42:25 UTC
Java team asked for evaluation as behaviour is similar to 53265
Comment 3 Tomas Hurka 2005-01-31 13:17:27 UTC

*** This issue has been marked as a duplicate of 53265 ***
Comment 4 Petr Blaha 2005-01-31 14:01:26 UTC
I was able to reproduce this issue in the latest daily build 20050130.
There are steps that I followed:
1) start IDE with empty userdit
2) go to File -> New Project -> select Enterprise category -> select
Enterprise application
3) click Next
4) specify project location, eg. /home/test/Project
5) click Next, the project is generated, the project includes one web
and ejb module by default
6) go to Versioning -> Versioning manager and add versioned directory
eg. /home/test/Project
7) initial checkout from CVS
8) go to project tab and select node representing J2EE application and
Add to repository
9) gto project tab and select EJB module node
10) right-click and select New - Session bean
11) specify package name and click Finish and get Exception
Comment 5 Tomas Hurka 2005-02-01 09:35:03 UTC
Problem is probably caused by cvs integration. FileUtil.isParentOf(root, file) returns false 
for
root = /tmp/J2eeApplication1111/J2eeApplication1111-ejb/src/java/
file = /tmp/J2eeApplication1111/J2eeApplication1111-ejb/src/java/test/

reassigning to vcscvs for further evaluation.
Comment 6 Martin Entlicher 2005-02-01 11:19:15 UTC
Impl. of FileUtil.isParentOf() seems to be pretty clear. The only
suspicious thing seems to be:

if (folder.getFileSystem () != fo.getFileSystem ()) {
    return false;
}

But everything should come from the MasterFS anyway. What are the
instances of FileObjects that you give as arguments to isParentOf()
and what is the working directory of the CVS?
Comment 7 Martin Entlicher 2005-02-02 20:44:26 UTC
The reproduction of this depends on issue #54421.
Comment 8 Martin Entlicher 2005-02-02 20:55:29 UTC
Well, I get a lot of calls like:

isParentOf(MasterFileObject@124f39a[file:/D:/NETBEANS/SRC/nb_all/xtest/src/],
AbstractFileObject@a4480d[jar:file:/D:/NETBEANS/SRC/nb_all/xtest/lib/nbj
unit-ide.jar!/])
FS1 =
org.netbeans.modules.masterfs.MasterFileSystem[org.netbeans.modules.masterfs.MasterFileSystem@e5f3d2],
FS2 =
D:\NETBEANS\SRC\nb_all\xtest\lib\nbjunit-ide.jar[org.openide.filesystems.JarFileSystem@1766d9c]
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1155)
        at org.openide.filesystems.FileUtil.isParentOf(FileUtil.java:850)
        at
org.netbeans.modules.java.freeform.SourceLevelQueryImpl.getSourceLevel(SourceLevelQueryImpl.java:75)
        at
org.netbeans.modules.java.project.ProjectSourceLevelQueryImpl.getSourceLevel(ProjectSourceLevelQueryImpl.java:37)
        at
org.netbeans.api.java.queries.SourceLevelQuery.getSourceLevel(SourceLevelQuery.java:46)
        at
org.netbeans.modules.javacore.JMManager.getSourceLevel(JMManager.java:1057)
        at
org.netbeans.modules.javacore.JMManager.getRootURI(JMManager.java:1063)
        at
org.netbeans.modules.javacore.JMManager.cleanUpCodebases(JMManager.java:797)
        at
org.netbeans.modules.javacore.JMManager.access$500(JMManager.java:61)
        at
org.netbeans.modules.javacore.JMManager$4.run(JMManager.java:1156)
        at org.openide.util.Task.run(Task.java:189)
        at
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:330)
        at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:721)


Tomas, is this O.K. ??? It looks very strange. Someone is trying to
compare a folder with a file inside a Jar.
A lot of calls like this happens before I got issue #54421. Perhaps
it's somehow related??
Comment 9 Martin Entlicher 2005-02-03 14:05:48 UTC
I've went through the steps without problems. No NPE encountered, no
calls of FileUtil.isParentOf() accross filesystems.

Please specify better steps how to reproduce...
Comment 10 Tomas Hurka 2005-02-04 08:28:09 UTC
Martin, I don't know. I have no knowledge about implementation of getSourceLevel query. I 
think that this not related. BTW: I was able to reproduce it without any problems. 
Comment 11 Martin Entlicher 2005-02-08 10:28:49 UTC
I've finally reproduced the exception. It's necessary to specify a
package name that consists of several "folders". Like "p1.p2.p3". Not
just "p1".

However it did not help me to find the cause of the bug. I've verified
that the exception occurs only when a VCS filesystem is mounted (it's
not necessary to actually run any VCS commands). But it does not seem
to have anything with isParentOf().

I'm going to attach a log that I've generated with all calls to
isParentOf() which return false. There does not seem to be anything
wrong...
Comment 12 Martin Entlicher 2005-02-08 10:29:41 UTC
Created attachment 20242 [details]
The log with calls to isParentOf().
Comment 13 Martin Entlicher 2005-02-08 10:53:48 UTC
Moving to j2ee component, please be more specific about what does VCS
wrong. Thanks.
Comment 14 Martin Adamek 2005-02-10 16:38:13 UTC
I checked this code in FileUtil.isParentOf:
if (folder.getFileSystem () != fo.getFileSystem ()) {
    return false;
}
This issue occurs only if this condition returns false. Check
following example:
AbstractFileObject@1d5f0e6[file:/local/martin/tmp/cvs_pblaha/madamek/qqq3/src/java/]
MasterFileObject@164f383[file:/local/martin/tmp/cvs_pblaha/madamek/qqq3/src/java/qqq/NewSessionLocalBusiness.java]
Names are OK, but FileSystems are: CommandLineVcsFileSystem vs.
MasterFileSystem
Reassigning to vcscore
Comment 15 Martin Entlicher 2005-02-10 17:41:27 UTC
Apparently you get access to our FileObject. This should not happen.
Other modules should not know about FileObjects from VCS filesystems.
Just FileObjects from MasterFileSystem should be used.

I will probably need some help from J2EE developers to find the place
where our FileObjects are exposed...
Comment 16 Martin Entlicher 2005-02-10 17:50:20 UTC
It's strange that I did not encounter this kind of call (viz my
attachment). I'll play with that again...
Comment 17 Martin Adamek 2005-02-10 19:39:13 UTC
I found that if I modify mentioned condition like this:

if (folder.getFileSystem () != fo.getFileSystem ()) {
  String parentName = folder.getPath();
  String childName = fo.getPath();
  FileSystem parentFS = folder.getFileSystem();
  FileSystem childFS = fo.getFileSystem();
  assert (childName.indexOf(parentName) == 0 &&
!parentFS.equals(childFS)) : "### " + 
                        folder + ", " + fo;
  return false;
}

I am not able to reproduce issue. This condition will return false
only once - somewhere in Add or Commit process. Here is output of assert:

java.lang.AssertionError: ###
AbstractFileObject@ee765[file:/local/martin/tmp/cvs_pblaha/madamek/111/],
MasterFileObject@79ca2e[file:/local/martin/tmp/cvs_pblaha/madamek/111/src/]
        at org.openide.filesystems.FileUtil.isParentOf(Unknown Source)
        at org.openide.filesystems.FileUtil.getRelativePath(Unknown
Source)
        at
org.netbeans.spi.project.support.ant.SourcesHelper.remarkExternalRoots(SourcesHelper.java:278)
        at
org.netbeans.spi.project.support.ant.SourcesHelper.registerExternalRoots(SourcesHelper.java:242)
        at
org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject$2.run(EjbJarProject.java:241)
        at org.openide.util.Mutex.leave(Unknown Source)
        at org.openide.util.Mutex.readAccess(Unknown Source)
        at
org.netbeans.api.project.ProjectManager.findProject(ProjectManager.java:175)
        at
org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:63)
        at
org.netbeans.api.project.FileOwnerQuery.getOwner(FileOwnerQuery.java:68)
        at
org.netbeans.modules.j2ee.deployment.config.ConfigDataLoader.findPrimaryFile(ConfigDataLoader.java:146)
        at
org.openide.loaders.MultiFileLoader.findPrimaryFileImpl(MultiFileLoader.java:232)
        at
org.openide.loaders.MultiFileLoader.handleFindDataObject(MultiFileLoader.java:65)
        at
org.openide.loaders.DataObjectPool.handleFindDataObject(DataObjectPool.java:111)
        at
org.openide.loaders.DataLoader.findDataObject(DataLoader.java:358)
        at
org.openide.loaders.DataLoaderPool.findDataObject(DataLoaderPool.java:386)
        at
org.openide.loaders.DataLoaderPool.findDataObject(DataLoaderPool.java:346)
        at org.openide.loaders.DataObject.find(DataObject.java:459)
        at
org.netbeans.modules.vcscore.objectintegrity.VcsObjectIntegritySupport.run(VcsObjectIntegritySupport.java:308)
        at org.openide.util.Task.run(Unknown Source)
[catch] at org.openide.util.RequestProcessor$Task.run(Unknown Source)
        at org.openide.util.RequestProcessor$Processor.run(Unknown Source)

Hope this can help
Comment 18 Martin Entlicher 2005-02-11 09:57:13 UTC
Thanks for that info! That helps a lot.
It seems like the responsible is VcsObjectIntegritySupport. It creates
DataObjects on VCS FS.
Comment 19 Martin Entlicher 2005-02-11 14:57:56 UTC
It's assured that DataObject.find() is not called on FileObjects that
come from VCS filesystem. This seems to fix this.
I did not encounter any NPE after this change, please verify.

/cvs/vcscore/src/org/netbeans/modules/vcscore/VcsAttributes.java,v 
<--  VcsAttributes.java
new revision: 1.42; previous revision: 1.41

/cvs/vcscore/src/org/netbeans/modules/vcscore/VcsFileSystem.java,v 
<--  VcsFileSystem.java
new revision: 1.316; previous revision: 1.315

/cvs/vcscore/src/org/netbeans/modules/vcscore/commands/CommandCustomizationSupport.java,v
 <--  CommandCustomizationSupport.java
new revision: 1.45; previous revision: 1.44

/cvs/vcscore/src/org/netbeans/modules/vcscore/commands/CommandExecutorSupport.java,v
 <--  CommandExecutorSupport.java
new revision: 1.74; previous revision: 1.73

/cvs/vcscore/src/org/netbeans/modules/vcscore/grouping/MainVcsGroupChildren.java,v
 <--  MainVcsGroupChildren.java
new revision: 1.10; previous revision: 1.9

/cvs/vcscore/src/org/netbeans/modules/vcscore/objectintegrity/VcsObjectIntegritySupport.java,v
 <--  VcsObjectIntegritySupport.java
new revision: 1.25; previous revision: 1.24

/cvs/vcscore/src/org/netbeans/modules/vcscore/util/VcsUtilities.java,v
 <--  VcsUtilities.java
new revision: 1.47; previous revision: 1.46

/cvs/vcscore/src/org/netbeans/modules/vcscore/versioning/impl/FileSystemNode.java,v
 <--  FileSystemNode.java
new revision: 1.8; previous revision: 1.7

/cvs/vcscore/src/org/netbeans/modules/vcscore/versioning/impl/FolderNode.java,v
 <--  FolderNode.java
new revision: 1.15; previous revision: 1.14
Comment 20 Martin Adamek 2005-02-11 19:58:48 UTC
Works for me, thanks!
Comment 21 Petr Blaha 2005-02-15 10:18:42 UTC
[Build 20050214]