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 43665

Summary: Cannot use existing directory when creating new project from existing sources
Product: projects Reporter: _ tboudreau <tboudreau>
Component: AntAssignee: Tomas Zezula <tzezula>
Status: RESOLVED FIXED    
Severity: blocker CC: jchalupa, jglick, rmatous
Priority: P2    
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 42421    
Bug Blocks: 42682    
Attachments: exc stack trace
Exception stack trace
exc stack trace

Description _ tboudreau 2004-05-21 13:04:52 UTC
I downloaded the sources to Ant and created a new freeform 
project with it.  But I forgot to set the proper source directory in 
the wizard, so I got a new project with the same source dir as 
the last freeform project I created.

So I opened a shell and rm -Rf'd the project I already had, then 
ran New Project again to create the project correctly.  After the 
wizard completed there was a long pause, and then:

(probably the project generator should ensure the dir really 
exists before throwing this exception)

java.lang.IllegalArgumentException: Already a project in 
MasterFileObject@99108f[file:/Users/tim/AntItself/]
	at 
org.netbeans.spi.project.support.ant.ProjectGenerator$1.run(Pro
jectGenerator.java:78)
	at org.openide.util.Mutex.writeAccess(Mutex.java:298)
	at 
org.netbeans.spi.project.support.ant.ProjectGenerator.createProj
ect(ProjectGenerator.java:75)
	at 
org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.cre
ateProject(J2SEProjectGenerator.java:108)
	at 
org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.cre
ateProject(J2SEProjectGenerator.java:73)
	at 
org.netbeans.modules.java.j2seproject.ui.wizards.NewJ2SEProjec
tWizardIterator.instantiate(NewJ2SEProjectWizardIterator.java:
100)
	at 
org.openide.loaders.TemplateWizard$Brigde2Iterator.instantiate(
TemplateWizard.java:945)
	at 
org.openide.loaders.TemplateWizard.handleInstantiate(Template
Wizard.java:537)
	at 
org.openide.loaders.TemplateWizard.instantiateImpl(TemplateWi
zard.java:453)
	at 
org.openide.loaders.TemplateWizard.instantiate(TemplateWizard
.java:339)
	at 
org.netbeans.modules.project.ui.actions.NewProject.actionPerfor
med(NewProject.java:55)
	at 
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.j
ava:1819)
	at 
javax.swing.AbstractButton$ForwardActionEvents.actionPerform
ed(AbstractButton.java:1872)
	at 
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButt
onModel.java:420)
	at 
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.
java:258)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:
321)
	at 
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemU
I.java:1113)
	at 
javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mo
useReleased(BasicMenuItemUI.java:943)
	at 
java.awt.Component.processMouseEvent(Component.java:5100)
	at java.awt.Component.processEvent(Component.java:
4897)
	at java.awt.Container.processEvent(Container.java:1569)
	at java.awt.Component.dispatchEventImpl(Component.java:
3615)
	at java.awt.Container.dispatchEventImpl(Container.java:
1627)
	at java.awt.Component.dispatchEvent(Component.java:
3477)
	at 
java.awt.LightweightDispatcher.retargetMouseEvent(Container.ja
va:3483)
	at 
java.awt.LightweightDispatcher.processMouseEvent(Container.ja
va:3198)
	at 
java.awt.LightweightDispatcher.dispatchEvent(Container.java:
3128)
	at java.awt.Container.dispatchEventImpl(Container.java:
1613)
	at java.awt.Window.dispatchEventImpl(Window.java:1606)
	at java.awt.Component.dispatchEvent(Component.java:
3477)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:
479)
	at 
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Event
DispatchThread.java:234)
	at 
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDis
patchThread.java:184)
	at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread
.java:178)
	at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread
.java:170)
	at 
java.awt.EventDispatchThread.run(EventDispatchThread.java:
100)
Comment 1 Jesse Glick 2004-05-21 16:27:37 UTC
I believe this is a dupe of an already filed robustness bug.

BTW the reporter incorrectly said that he was trying to make a
freeform project. This is a regular j2seproject from existing sources.
Comment 2 Milan Kubec 2004-05-24 16:21:55 UTC
I got exactly the same exception when doing similar thing. I closed
project becasue it had wrong metadata, then I deleted that project
from disk and then I wanted to create new project with the same name
-> exc. Raising prio to  P3.
Comment 3 Tomas Zezula 2004-05-25 13:31:37 UTC
The New Project Wizard correctly allows user to create new Project
since the old project dir is deleted but the
ProjectManager.getDefault().findProject(directory) returned project
for the deleted directory. ProjectGenerator can not heal from this and
throws Exception.
The actual problem is in the rm -rf (external command does not refresh
filesystems).
Comment 4 Jesse Glick 2004-05-25 18:09:12 UTC
Agreed that that is likely the problem. Lowering priority since it was
a user error not to refresh files after making external changes with
the IDE open. However the j2seproject wizard could attempt to refresh
the filesystem associated with the target directory. If the refresh
shows the dir as being removed, that should cause
FileUtil.toFileObject to create a fresh FileObject for the dir when it
is created, meaning ProjectManager will not report a problem (since
the cache key is FileObject). Will it work?
Comment 5 _ tboudreau 2004-05-25 18:17:03 UTC
Sounds good to me.
Comment 6 Tomas Zezula 2004-06-02 17:51:50 UTC
Currently the FileSystem where the project folder is created is
refreshed (J2SEProjectGenerator.createProjectDir(File).
I can't reproduce it anymore.
Comment 7 Milan Kubec 2004-06-07 14:13:38 UTC
Just reproduced on custom build 20040607, JDK 1.5.0 b51a. I closed
particular project then I renamed it on disk outside of IDE and then I
wanted to create new project with the same name.
Comment 8 Milan Kubec 2004-06-07 14:14:08 UTC
Created attachment 15525 [details]
exc stack trace
Comment 9 Jesse Glick 2004-06-07 15:01:40 UTC
No plans to support that in D I think, sorry. Requires additions to
project API and various kinds of infrastructure to support it. Restart
the IDE.
Comment 10 Tomas Zezula 2004-06-07 16:23:46 UTC
OK.
I will at least try to forbid the user to enter such a directory and
not to throw the exception.
This may be enough as a fix of this issue.
Comment 11 Jan Chalupa 2004-06-21 14:53:16 UTC
Hmm, I think this is a problem. I ran into this myself and heard from
3 other people that it happened to them too. The biggest problem I see
that a *closed* project is cached by the IDE and starts throwing
errors after external changes like rename, move, delete. This is very
confusing for the user, because she believes the project is really
closed and making external modifications should be perfectly fine.
IMO, this is a P2 bug.
Comment 12 Tomas Zezula 2004-06-21 16:57:55 UTC
I've tried to delete externally the closed project and to create new
one on the same place with the same name and no exception is thrown.
I also tried to move closed project and reopen it also no exception.
Could you add more details what you mean by edit or move and attach
the stack trace of exceptions?
Comment 13 Jan Chalupa 2004-06-21 17:21:03 UTC
Sure. See the attached exceptions. All I did was:

1. Open an existing project.
2. Close it.
3. Delete the project folder externally.
4. Go back to the IDE. Exception is thrown.

Comment 14 Jan Chalupa 2004-06-21 17:21:44 UTC
Created attachment 15894 [details]
Exception stack trace
Comment 15 Tomas Zezula 2004-06-21 17:43:57 UTC
The attached exception was already fixed this morning in the
java/j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/DefaultClassPathProvider.java
revision 1.3
Comment 16 Milan Kubec 2004-07-27 12:34:05 UTC
Doesn't seem to be fixed. I've reproduced Tim's exc again in custom
build 20040727 on JDK 1.5.0 b58.

My Steps:
I had opened freeform project that I closed. Then I deleted that
project on filesystem outside of IDE and wanted to create the project
with the same name again - I got the exception.
Comment 17 Milan Kubec 2004-07-27 12:34:57 UTC
Created attachment 16482 [details]
exc stack trace
Comment 18 Jesse Glick 2004-07-27 16:20:02 UTC
Note that the current description is using a freeform project, not a
j2seproject.

Might be a masterfs problem. If you delete a project dir on disk and
switch to the IDE (give it focus), that should cause a refresh, which
should invalidate the old project dir FileObject. While the
ProjectManager may continue to have it in cache, any subsequent wizard
should not get the same FileObject back, since it represented a
deleted directory, even if a dir of the same name is created again.
(Radek, is that correct?)
Comment 19 Tomas Zezula 2004-07-28 15:18:01 UTC
Added refresh before project dir is created to notify FS about change.
It is safer than depending on window focus.

Checking in
ant/freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java;
/cvs/ant/freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java,v
 <--  FreeformProjectGenerator.java
new revision: 1.18; previous revision: 1.17
done
Processing log script arguments...
More commits to come...
Checking in
java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectGenerator.java;
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectGenerator.java,v
 <--  J2SEProjectGenerator.java
new revision: 1.20; previous revision: 1.19
done
Comment 20 Jesse Glick 2004-07-28 22:28:36 UTC
Note: I also modified ProjectManager to remove any cache entries for
folders that are deleted (acc. to fileFolderDeleted). As I mentioned
in the last comment, it shouldn't matter, but maybe that will make
things a bit safer.