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 235603 - Context root not detected correctly from glassfish-web.xml
Summary: Context root not detected correctly from glassfish-web.xml
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.3.1
Hardware: PC Mac OS X
: P2 normal with 1 vote (vote)
Assignee: Martin Janicek
URL:
Keywords: 7.4_HR_FIX
Depends on:
Blocks:
 
Reported: 2013-09-06 11:44 UTC by Petr Jiricka
Modified: 2013-09-20 20:41 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Test case (2.92 KB, application/zip)
2013-09-12 12:29 UTC, Petr Jiricka
Details
patch (3.24 KB, patch)
2013-09-17 08:57 UTC, Petr Hejl
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2013-09-06 11:44:39 UTC
1. Register GF 4 in NetBeans
2. I have an existing Maven web project (which I will send to you privately), open it in NetBeans
3. Go to Project Properties -> Run

=> Context Path says '/ChessServer', although glasfish-web.xml contains:
    <context-root>/chess</context-root>

The workaround is to restart NetBeans, then it works fine.
Comment 1 Martin Janicek 2013-09-09 08:20:40 UTC
Sounds similar to issue 228939
Comment 2 TomasKraus 2013-09-10 11:28:26 UTC
When opening form there is no server selected:
----------------------------------------------
org.netbeans.modules.j2ee.deployment.config.ConfigSupportImpl.getWebContextRoot(ConfigSupportImpl.java:251)
org.netbeans.modules.maven.j2ee.web.WebModuleImpl.getContextPath(WebModuleImpl.java:358)
org.netbeans.modules.web.api.webmodule.WebModule.getContextPath(WebModule.java:197)
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.<init>(CustomizerRunWeb.java:104)

ConfigSupportImpl.getWebContextRoot() returns null and WebModuleImpl.getContextPath() uses Maven artifact ID to build context root.

Later CustomizerRunWeb.updateContextPathEnablement() is doing first initialization of teXt field:
-------------------------------------------------------------------------------------------------
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.updateContextPathEnablement(CustomizerRunWeb.java:395)
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.initValues(CustomizerRunWeb.java:201)
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.<init>(CustomizerRunWeb.java:107)

Here oldContextPath is initialized to previous value stored in contextPathTField - which is context root previously build from artifact ID.

After changing server to GlassFish:
-----------------------------------
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.updateContextPathEnablement(CustomizerRunWeb.java:391)
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.serverCBoxActionPerformed(CustomizerRunWeb.java:387)
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.access$100(CustomizerRunWeb.java:78)
org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb$2.actionPerformed(CustomizerRunWeb.java:286)

oldContextPath contains ontext root previously build from artifact ID so it is being used without an attempt to retrieve new value stored in glasfish-web.xml.

GHlassFish plugin is not being called to provide <context-root>/chess</context-root> value.
Comment 3 TomasKraus 2013-09-10 11:32:26 UTC
This seems to be problem in customizer form. Assigning to Martin who wrote it.
Comment 4 Martin Janicek 2013-09-10 13:16:55 UTC
Fixed by web-main #79a7ebc0e3bd

Works fine with my testing project, but would be good if you could test it as well? Thanks
Comment 5 Quality Engineering 2013-09-11 01:41:48 UTC
Integrated into 'main-silver', will be available in build *201309110001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/79a7ebc0e3bd
User: Martin Janicek <mjanicek@netbeans.org>
Log: #235603 - Context root not detected correctly from glassfish-web.xml
Comment 6 Petr Jiricka 2013-09-11 08:40:31 UTC
I am afraid it still does not work for me in build web-main#11577.
Comment 7 Martin Janicek 2013-09-12 10:20:05 UTC
I'm not able to reproduce it using following steps: (after #79a7ebc0e3bd)

1/ Create Maven Web application - GF4, Java EE 7
2/ Change context path to /abc
3/ Close IDE
4/ Clean userdir
5/ Start IDE
6/ Register GF
7/ Open project
8/ Go to project properties --> I can see /abc in context path which is correct

Do we have any other steps (except your project) how to reproduce it? I'm little bit confused about the Chess app to be honest :)
Comment 8 Petr Jiricka 2013-09-12 12:29:34 UTC
Created attachment 139984 [details]
Test case

I am attaching a test case which reproduces this as follows:
1. Start IDE with empty userdir (with ergonomics)
2. Enable Java EE features (e.g. New -> Web Project -> Cancel)
3. Register GlassFish
4. Open the attached project
5. Go to Project properties | Run

You should also be able to reproduce if you add this step to your steps:
3a. Delete nb-configuration.xml
Comment 9 Martin Janicek 2013-09-12 13:11:47 UTC
Thanks a lot. I'm somehow able to reproduce with a small differences. For example when I opened the project properties for the first time I see "No Server Selected" (that's IMHO correct because the server isn't configured in project files) so I need to change to newly registered GF4 (it will create nb-configuration which is fine as well). But after confirmation and opening project properties again I can see context path with "/Test235603" value --> that's wrong.
Comment 10 Marian Mirilovic 2013-09-12 14:34:13 UTC
7.4 candidate ?
Comment 11 Petr Jiricka 2013-09-12 14:44:38 UTC
Possibly, we'll see for sure when Martin finds the root cause and fix.
Comment 12 edburns 2013-09-14 09:28:41 UTC
This one is also impacting the Mojarra automated test development.  We rely heavily on glassfish-web.xml being the source of truth for the context root so that the HtmlUnit tests can find the app they are trying to test.
Comment 13 Petr Hejl 2013-09-16 10:25:27 UTC
The problem is imo maven j2ee customizer. When it loads it hiddenly ask for context root. In the situation there is no server it will receive the default. Now when the server is selected the context path field is enabled and this value is placed there (the default one). Now you click ok and the server and the context path is stored. Thus the default value is stored overwriting the one from deployment descriptor.
Comment 14 Petr Hejl 2013-09-16 12:04:09 UTC
Unfortunately my attempt to fix this has failed. Current project/server infrastructure allow to query the context path for the current server assigned to the project. While we are in the dialog no server changes are done yet and thus we can't really query and fill in the proper context path.

I don't think it would be safe to fix this issue for 7.4.
Comment 15 Petr Jiricka 2013-09-16 12:42:05 UTC
Thanks for investigation and evaluation Petr. 

> While we are in the dialog no server changes are done yet

Well, this is the other weird thing. As we discussed, if you change the server in properties, cancel the dialog and reopen it, the selected server sticks. Why is this, and where is it stored? The IDE does not create nb-configuration.xml, and with a clean userdir, it is reset. So it looks like this is stored in userdir - where?

I am thinking if it would be possible to partially fix as follows: when the user changes the server in the customizer, change the text in Context Path to something like "Confirm the dialog and reopen it in order to modify this field", and on confirming, the IDE would not overwrite any value in glassfish-web.xml. Is this doable?

Though one more weird thing is - just changing the server, canceling the dialog and reopening it is not a sufficient workaround - after that the context path is still incorrect. Only restarting the IDE helps and fixes the context path.
Comment 16 Petr Hejl 2013-09-16 13:57:45 UTC
(In reply to Petr Jiricka from comment #15)
> Thanks for investigation and evaluation Petr. 
> 
> > While we are in the dialog no server changes are done yet
> 
> Well, this is the other weird thing. As we discussed, if you change the
> server in properties, cancel the dialog and reopen it, the selected server
> sticks. Why is this, and where is it stored? The IDE does not create
> nb-configuration.xml, and with a clean userdir, it is reset. So it looks
> like this is stored in userdir - where?
I filed issue #236028.

> 
> I am thinking if it would be possible to partially fix as follows: when the
> user changes the server in the customizer, change the text in Context Path
> to something like "Confirm the dialog and reopen it in order to modify this
> field", and on confirming, the IDE would not overwrite any value in
> glassfish-web.xml. Is this doable?
I'll try that. I have been slowed down by issue #236028 and issue #236031.

> 
> Though one more weird thing is - just changing the server, canceling the
> dialog and reopening it is not a sufficient workaround - after that the
> context path is still incorrect. Only restarting the IDE helps and fixes the
> context path.
I think it is because the server is stored (to the disk) though no proper events fired as it is done when clicking "Ok". So far just my speculation.
Comment 17 Petr Hejl 2013-09-17 08:57:43 UTC
Created attachment 140164 [details]
patch

The patch attached. If the server is not selected when opening properties dialog the user has to select a server and confirm the dialog in order to change context path. If there is a server selected on dialog open the behavior is unchanged (can change the context path as long as there is a server selected in the server combo).

Should I proceed with integration of this patch to web-main and consequently to releases?
Comment 18 Petr Jiricka 2013-09-17 11:17:24 UTC
The fix looks reasonable, so I would put it in 7.4 after QA verification. Cc'ing Stepan.
Comment 19 Petr Hejl 2013-09-17 11:20:46 UTC
Fixed in web-main 8bc44076b1e5.
Comment 20 Martin Fousek 2013-09-17 11:42:18 UTC
(In reply to Petr Hejl from comment #19)
> Fixed in web-main 8bc44076b1e5.

The fix looks safe.
Comment 21 Quality Engineering 2013-09-18 02:09:08 UTC
Integrated into 'main-silver', will be available in build *201309180002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/8bc44076b1e5
User: Petr Hejl <phejl@netbeans.org>
Log: #235603 - Context root not detected correctly from glassfish-web.xml
Comment 22 Petr Hejl 2013-09-18 07:08:13 UTC
Stepane may I integrate it to releases?
Comment 23 Stepan Zebra 2013-09-18 08:16:37 UTC
verified in trunk, please integrate
Comment 24 Petr Hejl 2013-09-18 08:46:31 UTC
Fixed in releases 1864107f46d5.
Comment 25 edburns 2013-09-20 20:41:34 UTC
I'm happy to report this works for me in RC1.  

Great job!