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 231319 - [74cat] ClassCastException: org.netbeans.modules.cnd.makeproject.MakeProject cannot be cast to org.netbeans.modules.web.clientproject.ClientSideProject
Summary: [74cat] ClassCastException: org.netbeans.modules.cnd.makeproject.MakeProject ...
Status: CLOSED WONTFIX
Alias: None
Product: web
Classification: Unclassified
Component: HTML Project (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: David Konecny
URL:
Keywords:
: 232340 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-06-16 15:43 UTC by kosmonaffft
Modified: 2013-09-02 10:11 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 200701


Attachments
stacktrace (1.37 KB, text/plain)
2013-06-16 15:43 UTC, kosmonaffft
Details
Test C++ project for bug reproducing... (72.10 KB, application/octet-stream)
2013-07-08 02:59 UTC, kosmonaffft
Details
stacktrace (1.33 KB, text/plain)
2013-07-08 02:59 UTC, kosmonaffft
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kosmonaffft 2013-06-16 15:43:52 UTC
Build: NetBeans IDE 7.4 Beta (Build 201306132201)
VM: Java HotSpot(TM) 64-Bit Server VM, 23.21-b01, Java(TM) SE Runtime Environment, 1.7.0_21-b11
OS: Windows Server 2012

User Comments:
kosmonaFFFt: Try to create new HTML5 app project with existing sources...




Stacktrace: 
java.lang.ClassCastException: org.netbeans.modules.cnd.makeproject.MakeProject cannot be cast to org.netbeans.modules.web.clientproject.ClientSideProject
   at org.netbeans.modules.web.clientproject.util.ClientSideProjectUtilities.setupProject(ClientSideProjectUtilities.java:128)
   at org.netbeans.modules.web.clientproject.ui.wizard.ClientSideProjectWizardIterator.instantiate(ClientSideProjectWizardIterator.java:148)
   at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1044)
   at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:605)
   at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:439)
   at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:253)
Comment 1 kosmonaffft 2013-06-16 15:43:54 UTC
Created attachment 135852 [details]
stacktrace
Comment 2 David Konecny 2013-06-17 02:07:33 UTC
Could you tell us a bit about your directory structure? Where exactly are you trying to create HTML5 project? From the exception it looks like the folder you are creating HTML5 project in already has a makefile and the C++ support project gets into conflict with HTML5 about ownership. I would think that C++ support for makefiles is at wrong here and should have reported the folder earlier to prevent HTML5 project from re-using the folder.

Tomas, what's your opinion on this issue?
Comment 3 kosmonaffft 2013-06-17 04:13:13 UTC
Hello...

I have CMake-based C++ project, and inside it i have the "html" folder with HTML application. Exception occured when i try to create HTML5 application with root in the "html" folder. C++ project was opened at this moment...

(In reply to comment #2)
> Could you tell us a bit about your directory structure? Where exactly are you
> trying to create HTML5 project? From the exception it looks like the folder you
> are creating HTML5 project in already has a makefile and the C++ support
> project gets into conflict with HTML5 about ownership. I would think that C++
> support for makefiles is at wrong here and should have reported the folder
> earlier to prevent HTML5 project from re-using the folder.
> 
> Tomas, what's your opinion on this issue?
Comment 4 David Konecny 2013-06-17 04:21:08 UTC
Tomas, could you look into it please?
Comment 5 Tomas Mysik 2013-06-17 07:03:56 UTC
AFAIK, this scenario is not supported - see [1]. We already had a similar issue for PHP support - see issue #224799. I will improve the wizard. Please, let me know if I am wrong.

Thanks.
[1] http://wiki.netbeans.org/FaqSourceRootOverlap
Comment 6 Tomas Mysik 2013-06-17 07:29:25 UTC
So it seems that I was wrong and nested projects are (generally) supported so please ignore my last comment...

However, I am not able to reproduce your issue - I can create an HTML5 project in an existing project (PHP project in my case) without any problem... Could you please try it once more? Or are there any exact steps I have to do? Simply reopen this issue.

@mkleint: In any case, the problem seems to be in AntProjectHelper.createProject() - it should return the newly created HTML5 project and not C++ project (but as I wrote, it works for me properly). Miloši, can you confirm that?

Thanks.
Comment 7 Tomas Mysik 2013-06-17 07:37:17 UTC
(In reply to comment #6)
> @mkleint: In any case, the problem seems to be in
> AntProjectHelper.createProject() - it should return the newly created HTML5
> project and not C++ project (but as I wrote, it works for me properly). Miloši,
> can you confirm that?

Sorry, not precise. The code is:

AntProjectHelper projectHelper = ProjectGenerator.createProject(dirFO, ClientSideProjectType.TYPE);
setProjectName(projectHelper, name);
ClientSideProject project = (ClientSideProject) FileOwnerQuery.getOwner(dirFO);

The problem is on the last line, C++ project is returned and not the HTML5 one.

Thanks.
Comment 8 Milos Kleint 2013-06-17 08:34:23 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > @mkleint: In any case, the problem seems to be in
> > AntProjectHelper.createProject() - it should return the newly created HTML5
> > project and not C++ project (but as I wrote, it works for me properly). Miloši,
> > can you confirm that?
> 
> Sorry, not precise. The code is:
> 
> AntProjectHelper projectHelper = ProjectGenerator.createProject(dirFO,
> ClientSideProjectType.TYPE);
> setProjectName(projectHelper, name);
> ClientSideProject project = (ClientSideProject) FileOwnerQuery.getOwner(dirFO);

in any case, you should never cast the project. it could be also the FeatureOnDemand proxy one.. use project.getLookup(ClientSideProject.class) or some similar pattern.


The problem here could be not primary related to nesting existing projects but creation of a new project within an existing project. I'm sure it would work the other way around, when creating the html project first and then create a C++ project around it. 

You might want to consider calling ProjectManager.clearNonProjectCache() before attempting FOQ.getOwner()

Also please note that C++ projects have a different definition of what belongs to the project (their config files contain a list of files belonging to the projects, so they likely have their own FOQImplementation that reports ownership based on their config file). Has the html folder been included in the c++ project?

> 
> The problem is on the last line, C++ project is returned and not the HTML5 one.
> 
> Thanks.
Comment 9 Tomas Mysik 2013-06-17 11:06:26 UTC
Thanks a lot Miloši for your comment, I will do the changes in HTML5 project code.

(In reply to comment #8)
> Has the html folder been included in the c++ project?

This must be confirmed by reporter, I have no idea (so keeping resolved as INCOMPLETE).

Thanks.
Comment 10 Tomas Mysik 2013-06-17 11:57:15 UTC
(In reply to comment #9)
> Thanks a lot Miloši for your comment, I will do the changes in HTML5 project
> code.

Done.

http://hg.netbeans.org/web-main/rev/50f29c90cca3
Comment 11 Quality Engineering 2013-06-18 14:49:38 UTC
Integrated into 'main-golden', will be available in build *201306181109* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/50f29c90cca3
User: Tomas Mysik <tmysik@netbeans.org>
Log: Minor improvements

Related to #231319.
Comment 12 kosmonaffft 2013-07-07 15:28:43 UTC
Now exception is another, see bug https://netbeans.org/bugzilla/show_bug.cgi?id=232340
Comment 13 David Konecny 2013-07-07 21:27:13 UTC
*** Bug 232340 has been marked as a duplicate of this bug. ***
Comment 14 David Konecny 2013-07-07 22:24:51 UTC
Please provide step by step instructions how to reproduce this problem from scratch. I tried it myself and it always works for me - I can create HTML5 project from existing sources for html files/folders from a C++ project. Thanks.
Comment 15 kosmonaffft 2013-07-08 02:59:22 UTC
Created attachment 136799 [details]
Test C++ project for bug reproducing...
Comment 16 kosmonaffft 2013-07-08 02:59:37 UTC
Created attachment 136800 [details]
stacktrace

Try to create new html 5 project inside C++ project...
Comment 17 kosmonaffft 2013-07-08 03:10:28 UTC
I've attached simply test project, for reproducing bug you need CMake, so steps are simply:
1) using cmake configure project with build directory "build"
2) in NB create "C++ project with existing sources" and select "custom" configuration mode
3) check "run configure script in subfolder", in textfield input "build", all other steps select default parameters
4) try to create html5 project with "html" folder as root - you will see exception...

(In reply to comment #14)
> Please provide step by step instructions how to reproduce this problem from
> scratch. I tried it myself and it always works for me - I can create HTML5
> project from existing sources for html files/folders from a C++ project.
> Thanks.
Comment 18 David Konecny 2013-07-08 04:14:10 UTC
Thanks, I can reproduce it now. 

It looks to me that cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProjectFileOwnerQuery.java claims any file under C++ project root to belong to C++ project.
Comment 19 Tomas Mysik 2013-07-08 04:53:21 UTC
(In reply to comment #18)
> It looks to me that
> cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProjectFileOwnerQuery.java
> claims any file under C++ project root to belong to C++ project.

Yes, this is what Miloš wrote in comment #8. IMHO bug in CND, not HTML5 project.

Thanks.
Comment 20 Tomas Mysik 2013-07-08 06:06:04 UTC
Reassigning to CND - please evaluate (see comment #18). Thanks.
Comment 21 Alexander Simon 2013-07-10 15:34:44 UTC
It is true: all files in C/C++ project source root belongs to C/C++ project.
To create nested project add nested source root folder in ignore folders pattern in parent project properties.
Comment 22 Milos Kleint 2013-07-10 16:47:45 UTC
(In reply to comment #21)
> It is true: all files in C/C++ project source root belongs to C/C++ project.
> To create nested project add nested source root folder in ignore folders
> pattern in parent project properties.

that's counterintuitive and makes c++ projects stand out. What was the reason for breaking the behaviour shared by other project types? (overriding the SimpleFileOwnerQueryImplementation behaviour)
Comment 23 Alexander Simon 2013-07-10 17:40:42 UTC
(In reply to comment #22)
> that's counterintuitive and makes c++ projects stand out. What was the reason
> for breaking the behaviour shared by other project types? (overriding the
> SimpleFileOwnerQueryImplementation behaviour)
Simple answer: SimpleFileOwnerQueryImplementation does not fit CND FOQ requirements (project folder can be different with source root).
By the way I do not see nested project problem except HTML5 project.
Comment 24 kosmonaffft 2013-07-17 04:40:04 UTC
So, is it possible to fix this issue?

(In reply to comment #23)
> (In reply to comment #22)
> > that's counterintuitive and makes c++ projects stand out. What was the reason
> > for breaking the behaviour shared by other project types? (overriding the
> > SimpleFileOwnerQueryImplementation behaviour)
> Simple answer: SimpleFileOwnerQueryImplementation does not fit CND FOQ
> requirements (project folder can be different with source root).
> By the way I do not see nested project problem except HTML5 project.
Comment 25 Alexander Simon 2013-07-17 07:13:11 UTC
(In reply to comment #24)
> So, is it possible to fix this issue?
Reassign the question back to exception owner.
Comment 26 David Konecny 2013-07-22 21:01:37 UTC
re. "is it possible to fix this issue?" - this was answered by Alexander in comment 21: "To create nested project add nested source root folder in ignore folders pattern in parent project properties."