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 131702 - UnsupportedOperationException at org.netbeans.api.java.project.classpath.ProjectClassPathModifier.addRoots
Summary: UnsupportedOperationException at org.netbeans.api.java.project.classpath.Proj...
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: David Konecny
URL: http://statistics.netbeans.org/except...
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2008-04-01 11:08 UTC by Dan Kolar
Modified: 2011-05-19 17:29 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 28205


Attachments
stacktrace (1.87 KB, text/plain)
2008-04-02 13:14 UTC, cbulcu
Details
stacktrace (1.87 KB, text/plain)
2008-04-09 12:27 UTC, tkellerer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Kolar 2008-04-01 11:08:47 UTC
Build: NetBeans IDE Dev (Build 200802161202)
VM: Java HotSpot(TM) Client VM, 1.6.0_02-b05
OS: Linux, 2.6.24.2-smp, i386

Exception raises after finishing New Web application with existing sources wizard.

STACKTRACE: (first 10 lines)
java.lang.UnsupportedOperationException
        at org.netbeans.api.java.project.classpath.ProjectClassPathModifier.addRoots(ProjectClassPathModifier.java:177)
        at org.netbeans.modules.web.project.api.WebProjectUtilities.importProjectImpl(WebProjectUtilities.java:543)
        at org.netbeans.modules.web.project.api.WebProjectUtilities.access$200(WebProjectUtilities.java:106)
        at org.netbeans.modules.web.project.api.WebProjectUtilities$3.run(WebProjectUtilities.java:419)
        at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120)
        at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:499)
        at org.netbeans.modules.web.project.api.WebProjectUtilities.importProject(WebProjectUtilities.java:417)
        at
org.netbeans.modules.web.project.ui.wizards.ImportWebProjectWizardIterator.instantiate(ImportWebProjectWizardIterator.java:196)
        at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1023)
        at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:595)
Comment 1 cbulcu 2008-04-02 13:14:08 UTC
Build: NetBeans IDE Dev (Build 200803251204)
VM: Java HotSpot(TM) Client VM, 1.6.0_03-b05, Java(TM) SE Runtime Environment, 1.6.0_03-b05
OS: Windows XP, 5.1, x86

User Comments: 
Comment 2 cbulcu 2008-04-02 13:14:11 UTC
Created attachment 59542 [details]
stacktrace
Comment 3 Tomas Zezula 2008-04-02 14:22:51 UTC
Wrong component.
Either web project doesn't provide required SPI or caller passes wrong projectArtifact.
Comment 4 David Konecny 2008-04-03 00:48:12 UTC
tzezula, the problem is in projectArtifact. Web import wizard adds all jars found in web-inf/lib to project classpath.
If sources folder is specified in wizard but is outside of project folder then you get this exception. Other problem I
discovered was that not entering any sources folder fails with ArrayIndexOutOfBoundsException. How do you think this
should be resolved? One idea is to call directly web implementation of ProjectClassPathModifierImplementation and add
the jars always to java.classpath. Thanks, -D
Comment 5 Tomas Zezula 2008-04-03 08:02:34 UTC
This is a problem of the SimpleFileOwnerQuery.markExternalOwnerTransient which is called from project's open hook. In the time when the project is not yet 
opened the source root you are passing to the PCPM does not belong to any project. You should either add it into the property as you described or delay the 
addition to the time the project is opened. Another but very ugly solution is to register the owner for the root in the wizard and unregister it after adding the 
root.
Unfortunately the PCPM needs the source root because the projects with multiple compilation units, the project itself doesn't describe the java compilation 
unit since there are more of them (src, test) having different classpaths.
Comment 6 tkellerer 2008-04-09 12:27:42 UTC
Build: NetBeans IDE Dev (Build 200804060002)
VM: Java HotSpot(TM) Client VM, 11.0-b11, Java(TM) SE Runtime Environment, 1.6.0_10-beta-b14
OS: Windows XP, 5.1, x86

User Comments: 
Creating a web application from existing sources. Clicking finish
Comment 7 tkellerer 2008-04-09 12:27:46 UTC
Created attachment 59895 [details]
stacktrace
Comment 8 tkellerer 2008-04-09 12:34:33 UTC
As this issue effectively prevents the creation of a new project, I wonder why it's only P3? 
Shouldn't this be P1 to make sure it's fixed for 6.1??
Comment 9 Dan Kolar 2008-04-09 12:47:53 UTC
Good point.
Comment 10 Petr Blaha 2008-04-09 14:38:14 UTC
The exception is thrown when the sources folder is specified in wizard but is outside of project folder. It means the
workaround is to use default project folder offered by wizard. According the Quality criteria guideline
http://qa.netbeans.org/bugzilla/bug_priority_guidelines.html the bug is P2 and it's not stopper. Anyway, the annoying
bug will be fixed in patch1 for Nb 6.1.
Comment 11 Dan Kolar 2008-04-09 14:53:59 UTC
Workaround:In 'Name and Location' use default Project Folder location (i.e. Project Folder = Location) and exception
doesn't occure.
Comment 12 tkellerer 2008-04-09 15:17:02 UTC
From my point of view this is a regression, as this was working perfectly well in 5.0, 5.5 and 6.0

We never store the NB project directory in the actual source tree (as that is under version control and should not be
cluttered with non-versioned filed) so for me this is more or less a show stopper, and I'll need to wait for the post
6.1 version before I can migrate :(
Comment 13 tkellerer 2008-04-09 15:29:24 UTC
I just tried the suggested workaround and that doesn't work either. If I keep the default values for the project folder
I get a MissingResourceException when selecting the WEB-INF folder and the wizard complains "WEB-INF folder is
mandatory" even though I selected one. The exception has already been uploaded:
http://statistics.netbeans.org/analytics/detail.do?id=45139

The structure of the source is like this:

my_project
  src
    main 
      java (contains the java packages)
      webapp 
        WEB-INF
        META-INF
        css
        images
        (jsp files)

In the first page of the wizard I select "my_project/src/main/java" for the "Location" field. When doing this, the
wizard suggests to use my_project/src/main/java as the project folder (which doesn't really make sense). When I leave
these defaults (after changing the project's name from "java" to "my_project") I get the error "WEB-INF folder is
mandatory" error when selecting the WEB-INF folder.

So currently there is no way for me to create the project using NB 6.1
Comment 14 tkellerer 2008-04-09 15:35:39 UTC
The only workaround for me is to create the Project in NB 6.0 and then open it in 6.1 which seems to work without problems.
Comment 15 Tomas Zezula 2008-04-09 17:03:12 UTC
It seems to me as P1.
Comment 16 David Konecny 2008-04-09 23:27:06 UTC
tkellerer, I followed your files structure and can create project with existing source without problem. I chose:
Location: D:\projs\my_project
Project Folder: D:\projs\my_project
Web Pages Folder: D:\projs\my_project\src\main\webapp
WEB-INF Content: D:\projs\my_project\src\main\webapp\WEB-INF
Sources Packages Folder: D:\projs\my_project\src\main\java

I'm going to fix this issue today as well as MissingResourceException.
Comment 17 David Konecny 2008-04-09 23:45:01 UTC
I should have also said that I set:
Libraries Folder (on 4.panel - Existing Sources and Libraries panel): D:\projs\my_project\src\main\webapp\WEB-INF\lib
and made sure it contains some jar files.

In this setup everything passes. If however I on the 4. panel change Sources Packages Folders to a folder outside of
my_project folder, e.g. D:\projs\sources, then I'll get UnsupportedOperationException.
Comment 18 David Konecny 2008-04-10 02:11:30 UTC
This is regression from 6.0 - usage of deprecated API was replaced with new API which caused this problem.

The workaround is to specify a Java source root which lies under project folder.

Statistics shows 18 duplicates.

Fix is simple and isolated and will not cause regression if integrated to 6.1.

UnsupportedOperationException fixed in
http://hg.netbeans.org/main?cmd=changeset;node=b5f07b919bea

MissingResourceException fixed in
http://hg.netbeans.org/main?cmd=changeset;node=2c3809407a9d
Comment 19 Petr Blaha 2008-04-11 09:18:55 UTC
The bug is fixed in the build http://bits.netbeans.org/download/trunk/nightly/2008-04-11_02-01-00/
Comment 20 Dan Kolar 2008-04-14 14:06:34 UTC
v. in trunk
Comment 21 David Konecny 2008-04-15 22:31:02 UTC
Based on offline discussion with Petr Blaha fixinf in 6.1: 7a6ae9da24fc and c0c0aca09be0
Comment 22 Dan Kolar 2008-04-17 09:25:10 UTC
v. in 6.1 RC2
Comment 23 pslechta 2008-04-29 10:41:57 UTC
The changes proposed by this fix were already integrated in release61 repository and are part of NB 6.1 FCS build.
Clearing status whiteboard. This fix should not be part of NB 6.1 patch 1.
Comment 24 playwellness 2011-05-19 17:29:47 UTC
Comment on attachment 59542 [details]
stacktrace

>java.lang.UnsupportedOperationException
>        at org.netbeans.api.java.project.classpath.ProjectClassPathModifier.addRoots(ProjectClassPathModifier.java:177)
>        at org.netbeans.modules.web.project.api.WebProjectUtilities.importProjectImpl(WebProjectUtilities.java:554)
>        at org.netbeans.modules.web.project.api.WebProjectUtilities.access$200(WebProjectUtilities.java:108)
>        at org.netbeans.modules.web.project.api.WebProjectUtilities$3.run(WebProjectUtilities.java:425)
>        at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120)
>        at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:499)
>        at org.netbeans.modules.web.project.api.WebProjectUtilities.importProject(WebProjectUtilities.java:423)
>        at org.netbeans.modules.web.project.ui.wizards.ImportWebProjectWizardIterator.instantiate(ImportWebProjectWizardIterator.java:196)
>        at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1023)
>        at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:595)
>        at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:416)
>        at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:253)
>        at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:165)
>        at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1384)
>        at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1341)
>        at org.openide.WizardDescriptor.access$1600(WizardDescriptor.java:119)
>        at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:1908)
>        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
>        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)