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 177582 - Add Framework action removes the content od web.xml
Summary: Add Framework action removes the content od web.xml
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 6.x
Hardware: PC Linux
: P1 normal (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-25 06:12 UTC by Milan Kuchtiak
Modified: 2009-11-27 06:33 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kuchtiak 2009-11-25 06:12:00 UTC
Adding (probably any) framework to existing web module removes the actual content of web.xml.

Note: this is not related to issue 177370. I've tested the code before the fix, and after. It's the same.

Problem is IMHO, in calling 
WebProjectProperties:save() method 

shouldCreateWebXml() is called from there, which returns true, regardles web.xml exists or not.
Then web.xml is created all the time.

See : DDHelper.createWebXml(j2eeProfile, webInf); is called from WebProjectProperties:save() method.

There should be a test somewhere checking if web.xml exists or not.

Qualifying as P1 as user data are completely lost.
Comment 1 David Konecny 2009-11-25 17:09:40 UTC
fixed in 18a607365480
web.xml is created now only if it does not exist; I also added a check to DDHelper.createWebXml which throws IllegalStateException if web.xml should be overwritten to prevent similar issues in future and catch them earlier.
Comment 2 Milan Kuchtiak 2009-11-26 02:01:47 UTC
The fix seems to be fine.

Just small comment: the check of webInf for null isn't needed.
The project.getAPIWebModule().getDeploymentDescriptor() should return null in that case:

             Profile j2eeProfile = project.getAPIWebModule().getJ2eeProfile();
             FileObject webInf = project.getAPIWebModule().getWebInf();
-            if (shouldCreateWebXml() && webInf != null) {
+            FileObject ddFo = project.getAPIWebModule().getDeploymentDescriptor();
+            if (ddFo == null && shouldCreateWebXml() && webInf != null) {
                 DDHelper.createWebXml(j2eeProfile, webInf);
             }

Can you please push it to release68 repository after QA engineer approval ?
Comment 3 Martin Schovanek 2009-11-26 05:20:35 UTC
Verified at the web-main, please integrate into release68.
Comment 4 David Konecny 2009-11-26 15:43:38 UTC
transplanted to release68 as 2a55556e346f
Comment 5 Quality Engineering 2009-11-26 19:34:08 UTC
Integrated into 'main-golden', will be available in build *200911261400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/18a607365480
User: David Konecny <dkonecny@netbeans.org>
Log: Bug #177582 - Add Framework action removes the content od web.xml
Comment 6 Martin Schovanek 2009-11-27 06:33:45 UTC
Verified at the release68.