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 177370 - Multiview editor for web.xml sync problem
Summary: Multiview editor for web.xml sync problem
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: DD Editor (show other bugs)
Version: 6.x
Hardware: PC Mac OS X
: P1 normal (vote)
Assignee: Milan Kuchtiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-22 04:30 UTC by Michal Mocnak
Modified: 2009-11-26 02:39 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 Michal Mocnak 2009-11-22 04:30:33 UTC
Steps to reproduce:

1. open web.xml
2. choose servlets tab
3. add servlet entry
4. switch to xml view

=> xml is not synced with multiview data

5. switch back -> servlet is still there
6. save the file and switch again to xml view

=> still nothing

7. switch again back and add another servlet
8. switch to xml

=> now it's synced, from that moment everything work fine

It's marked as P2 cause it should be fixed in FCS -> not marking as P1 due to very clear workaround
Comment 1 Petr Jiricka 2009-11-23 02:20:49 UTC
Hi Michal, is this a regression?
Comment 2 Michal Mocnak 2009-11-23 05:13:50 UTC
Yes .. it's a regression from beta build. Upgrading back to P1 due to user data loss. Another scenario appeared. When you edited web.xml by yourself (add a new servlet manually) and then you would add servlet through wizard all previous servlets are lost from web.xml.
Comment 3 Milan Kuchtiak 2009-11-23 06:10:11 UTC
I cannot reproduce this issue on my linux :
Tested before and after schema updates (build 091123)

Is that MAC specific issue ?
Comment 4 Petr Jiricka 2009-11-23 09:02:35 UTC
I also can not reproduce.

Product Version: NetBeans IDE Dev (Build web-main-2148-on-091123)
Java: 1.6.0_15; Java HotSpot(TM) 64-Bit Server VM 14.1-b02-92
System: Mac OS X version 10.5.8 running on x86_64; MacRoman; en_US (nb)
Userdir: /Users/petrjiricka/.netbeans/dev
Comment 5 Milan Kuchtiak 2009-11-23 09:32:08 UTC
I also found some suspicious behaviour (#2 Michal Mocnak). Investigating further what's happening there.
Comment 6 Milan Kuchtiak 2009-11-23 12:26:08 UTC
This is a tough synchronization problem.
I found out, that XmlMultiviewElement:componentActivated/componentShowing methods are called prior to document (in cache) is updated from web.xml data model.
These methods likely need to be "synchronized" with XmlMultiviewEditorSupport:updatingDataFromModel(), or XmlMultiviewDataObject:saveData();
Comment 7 David Konecny 2009-11-23 18:20:42 UTC
I can reproduce it always on several NB versions (68 RC1, 68 Beta, NB 67). Again the problem was there probably always so I would suggest to fix it but I do not think it is showstopper.
Comment 8 David Konecny 2009-11-23 21:19:43 UTC
Milan, I make no progress on this issue today so feel free to continue. You seems to be author of many classes so perhaps it will be easier for you to fix. I had a look at Sun Deployment Descriptor (editor for sun-web.xml from j2ee.sun.ddui module) which synchronizes GUI/xml changes correctly but code is too different and too complex so I have not got far.
Comment 9 Milan Kuchtiak 2009-11-24 08:57:05 UTC
This is the fix:
http://hg.netbeans.org/main/rev/064fc2f6dca7

There are actually 2 problems:

1. problem (described by M.Mocnak in first description)
   This is the synchronization between web.xml graphical view and xml view

In this case the web.xml data model is saved to XML Multiview (text) cache, and the content of cache is used in editor. It happened that cache was modified sooner than web.xml model was changed.

   This was happening when DD data object was saved and (isModified() == false)
   The synchronization process started with different delay than the case when data object is modified.

The fix is based on using the same delay regardless the data object is modified or not.

2. problem (Michal Mocnak #2)

This issue was caused by improper implementation of the merge data model for deployment descriptor (model that accepts both annotation and web.xml)

In DDProider, WebApp object (representing dd data model) is cached.
Problem is that, instead of using this cached object (used also by DD Editor) the WebAppMetadataImpl works with another instance of WebApp.
Thus, when new servlet is added, using the wizard, web.xml is not changed in editor (that uses another WebApp instance)

The solution is to use the same instance as DD Editor.

QA engineer(reporter), please verify thoroughly the fix.
Thank You.
Comment 10 David Konecny 2009-11-24 13:52:50 UTC
I tested the patch and it seems to fix the issue.

It is hard to say what was the purpose of different scheduling of updateTask in XmlMultiViewDataSynchronizer.java. One thing which makes me little bit suspicious is that sun-web.xml worked fine even before the Milan's change. That seems to indicate that problem is somewhere else than in XmlMultiViewDataSynchronizer. Also now you can notice delay in updating: change servlet name in GUI and immediately switch to XML view and you will see old servlet name being replaced with new one. sun-web.xml does not have this update issue.
Comment 11 Michal Mocnak 2009-11-25 01:38:30 UTC
Great ... it's working (verified in main)
Comment 12 Milan Kuchtiak 2009-11-25 02:19:58 UTC
>One thing which makes me little bit
suspicious is that sun-web.xml worked fine even before the Milan's change. That
seems to indicate that problem is somewhere else than in XmlMultiViewDataSynchronizer.

There a different delay regarding DataObject is modified or not. I've just unified the delay.
Moreover, web.xml editing differs little bit from sub-web.xml eidting, which doesn't use modal dialogs (like in Add Servlet). 

>Also now you can notice delay in updating: change
servlet name in GUI and immediately switch to XML view and you will see old
servlet name being replaced with new one. sun-web.xml does not have this update
issue. 

That's the same as before, providing the data object is modified (not saved).

Michal, can you pleaase test also sun-web.xml editing ?
Comment 13 Michal Mocnak 2009-11-25 02:40:05 UTC
i have tried it and it seems to be ok ... all is well synced
Comment 14 Milan Kuchtiak 2009-11-25 07:35:00 UTC
Fixed in release68:
http://hg.netbeans.org/release68/rev/5554ed70dff9
Comment 15 Quality Engineering 2009-11-25 16:54:22 UTC
Integrated into 'main-golden', will be available in build *200911251400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/064fc2f6dca7
User: mkuchtiak@netbeans.org
Log: #177370: fixing 2 problems with web.xml synchronization
Comment 16 Michal Mocnak 2009-11-26 02:39:02 UTC
Verified in rc1 build