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 165149

Summary: IllegalStateException: registerExternalRoots was already called
Product: projects Reporter: Ivan Sidorkin <ivansidorkin>
Component: Ant ProjectAssignee: Jesse Glick <jglick>
Status: RESOLVED FIXED    
Severity: blocker CC: dkonecny, mkubec, ovk
Priority: P3 Keywords: RANDOM, THREAD
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=150441
Issue Type: DEFECT Exception Reporter: 150441
Bug Depends on:    
Bug Blocks: 146852    
Attachments: stacktrace
stacktrace

Description Ivan Sidorkin 2009-05-14 11:21:11 UTC
Build: NetBeans IDE Dev (Build 200905140201)
VM: Java HotSpot(TM) 64-Bit Server VM, 11.3-b02, Java(TM) SE Runtime Environment, 1.6.0_13-b02
OS: Linux, 2.6.27-11-generic, amd64

User Comments:
GUEST: Deleted all projects from an existing dummy enterprise project



Stacktrace: 
org.openide.util.RequestProcessor$Item: task failed: java.lang.IllegalStateException: registerExternalRoots was already called
        at org.openide.util.RequestProcessor$Item.fillInStackTrace(RequestProcessor.java:853)
        at java.lang.Throwable.<init>(Throwable.java:181)
        at java.lang.Exception.<init>(Exception.java:29)
        at org.openide.util.RequestProcessor$Item.<init>(RequestProcessor.java:819)
        at org.openide.util.RequestProcessor$Task.schedule(RequestProcessor.java:629)
        at org.openide.util.RequestProcessor.post(RequestProcessor.java:295)
Comment 1 Ivan Sidorkin 2009-05-14 11:21:18 UTC
Created attachment 82110 [details]
stacktrace
Comment 2 Milan Kubec 2009-05-14 12:05:13 UTC
Is it reproducible for you? If so, please describe step by step how to reproduce. Thanks.
Comment 3 Ivan Sidorkin 2009-05-14 12:53:30 UTC
steps described in first comment
I can't reproduce it again, but there are 3 exception reports so it happened time to time
Comment 4 Milan Kubec 2009-05-14 13:06:30 UTC
By steps I meant something like this:

1. Created Dummy EAR project
2. Selected WAR project under the EAR and invoked Delete action from its context menu, checked 'Delete also sources'
3. ...

From "Deleted all projects from an existing dummy enterprise project" - I don't know if you deleted all in one shot or
one after another, externally or from IDE, in what order etc.

Such description is very important mainly for issues that are not reproducible.
Comment 5 Oleg Khokhlov 2009-05-15 14:14:55 UTC
Build: NetBeans IDE Dev (Build 200905140201)
VM: Java HotSpot(TM) Client VM, 11.3-b02, Java(TM) SE Runtime Environment, 1.6.0_13-b03
OS: Windows XP, 5.1, x86

User Comments: 
- invoke "open project" dialog;
- choose project, press Del and delete the project within this dialog;


Stacktrace: 
java.lang.IllegalStateException: registerExternalRoots was already called
        at org.netbeans.spi.project.support.ant.SourcesHelper.addPrincipalSourceRoot(SourcesHelper.java:404)
        at org.netbeans.spi.project.support.ant.SourcesHelper.addPrincipalSourceRoot(SourcesHelper.java:365)
        at org.netbeans.modules.j2ee.earproject.EarSources.initSources(EarSources.java:92)
        at org.netbeans.modules.j2ee.earproject.EarSources.access$100(EarSources.java:60)
        at org.netbeans.modules.j2ee.earproject.EarSources$1.run(EarSources.java:81)
        at org.netbeans.modules.j2ee.earproject.EarSources$1.run(EarSources.java:78)
Comment 6 Oleg Khokhlov 2009-05-15 14:15:04 UTC
Created attachment 82194 [details]
stacktrace
Comment 7 Milan Kubec 2009-05-15 14:44:03 UTC
What project did you open? What project did you delete? Did you check "Delete also sources ..." checkbox? Thanks.
Comment 8 Oleg Khokhlov 2009-05-18 16:35:01 UTC
in my case it was this way:
- created new enterprise app;
- deleted it from Projects tab - "Delete also sources ..." checkbox was disabled;
- invoked "open project" dialog;
- there was my ent app listed (not as a project anymore but as a regulat folder);
- I clicked on it and pressed Del button (to delete a folder);
I've got error message box and then exception.
Comment 9 Oleg Khokhlov 2009-05-18 16:39:33 UTC
I've repeated these steps in build 0518 now and got another exception: filed as a bug 165425
Comment 10 Jesse Glick 2009-05-19 00:31:21 UTC
Possibly result of 23a442bff758. Looks like two threads calling initSources concurrently.
Comment 11 Jesse Glick 2009-05-19 04:17:14 UTC
Eight project types had *Sources impls which kept a SourcesHelper reference as an instance field, which is no longer
necessary - can use a local variable instead. Still a possible race condition that two SourcesHelper's will be created
in quick succession after some events are received, but for now this seems less important than the possible deadlocks
that could arise from trying to synchronize access to initSources.

Logic is a bit subtle since it is necessary to ensure that we always hold a hard reference to a SourcesHelper or its
corresponding Sources; otherwise it can be collected and fail to reregister external roots after evaluator changes.
(J2SESourcesTest demonstrates this.)

There should really be a common impl for all the *Sources in java.api.common so that fixes like this would not need to
be duplicated.

core-main #65b832eb0031
Comment 12 Quality Engineering 2009-05-19 18:40:06 UTC
Integrated into 'main-golden', will be available in build *200905191401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/65b832eb0031
User: Jesse Glick <jglick@netbeans.org>
Log: #165149: registerExternalRoots occasionally called >1x per SourcesHelper.