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 170248 - Web application not deployed correctly to GF v3 with empty context path
Summary: Web application not deployed correctly to GF v3 with empty context path
Status: VERIFIED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Nitya Doraisamy
URL:
Keywords:
Depends on:
Blocks: 161026
  Show dependency tree
 
Reported: 2009-08-12 09:30 UTC by Petr Jiricka
Modified: 2009-09-30 09:58 UTC (History)
1 user (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 Petr Jiricka 2009-08-12 09:30:13 UTC
1. Create a web application against GF v3, set the context path to empty string.
sun-web.xml is generated correctly with empty context root element:   <context-root/>
2. Deploy the application

Application will be deployed with context path corresponding to the application directory name, not with empty context path.
Comment 1 Vince Kraemer 2009-08-12 15:24:25 UTC
please look at this to see if there is an obvious fix.
Comment 2 _ pcw 2009-08-13 02:38:48 UTC
I'm pretty sure this is a bug.  What is unclear is if it is a NB V3 plugin bug or a GlassFish bug.  When the context-root field is present and empty (e.g. 
<context-root/>) in sun-web.xml, GlassFish does *not* deploy the application at the root context.  It is deployed at the default context (e.g. the name of the 
application).  I will ask the GF team is this intended behavior.  Since sun-web.xml is a proprietary descriptor, it is not a spec violation to do this.

I was able to deploy a web application at root context by specifying "context-root=<blank>" with the deploy command and this may be the intended way to 
make this work in which case, this is a bug in the V3 plugin.  In fact, I think I will update the V3 plugin to do this automatically regardless.
Comment 3 _ pcw 2009-08-13 02:39:41 UTC
Sorry Nitya... Petr had emailed the list and I'd already said I'd look at it.  You're welcome to fix it if you like.  I haven't changed anything yet.
Comment 4 Nitya Doraisamy 2009-09-23 19:04:08 UTC
Pinged the server team regarding this, the v3 server behavior is: 

- If you specify an empty element in deployment descriptor, that element is skipped and as if there is no context root
was provided and the application is deployed to the default context (e.g. the name of the application). 

To deploy to root context, the deploy command will need to specify context-root="" or context-root="/"
Comment 5 Petr Jiricka 2009-09-23 21:15:48 UTC
Confirmed, I am able to deploy to empty context path by manually changing context-root in sun-web.xml to:
<context-root>/</context-root>
Comment 6 Nitya Doraisamy 2009-09-24 00:13:51 UTC
That's right. But the 'Context Path' field in the project properties -> Run dialog does not accept '/' as a valid value.
So an empty Context Path field causes an empty context root (<context-root/>) in sun-web.xml

Like Peter suggested, I think the best option would be to update the plugin deploy command to pass the value of the
context root when empty as context-root="", so v3 will deploy the webapp at the root context. 
Comment 7 Nitya Doraisamy 2009-09-24 20:22:36 UTC
Fix in web-main repo. Waiting on build.
http://hg.netbeans.org/web-main/rev/90d0d3d8570e
Comment 8 Nitya Doraisamy 2009-09-25 02:11:02 UTC
Mark as fixed. See above for changeset
Comment 9 Petr Jiricka 2009-09-25 15:55:48 UTC
I can still reproduce in build web-main 1678 + GF build 65, using the original steps. 

If I understand correctly, are you saying that there is no way to specify in sun-web.xml that the path should be empty?
That sounds like a server bug to me: if I specify a non-empty path in sun-web.xml and then deploy the app using asadmin
without the --contextroot parameter, then the value in sun-web.xml is honored. So it should be honored also when path in
sun-web.xml is empty.
Comment 10 Vince Kraemer 2009-09-25 17:44:40 UTC
There is a way to specify the root context... 
 <context-root>/</context-root>

The IDE does not let us enter '/' in the text field that would become that value...

regarding...

> if I specify a non-empty path in sun-web.xml and then deploy the app using asadmin
> without the --contextroot parameter, then the value in sun-web.xml is honored. So 
> it should be honored also when path in sun-web.xml is empty.

Difference in perspective...

the server team assumes that if you do not specify the context-root the app should be deployed in a way which will
produce success not failure....

For example: take two apps that you 'found' on the internet, without a sun-web.xml file in them and you want to try them
out.

So, you deploy them...

asadmin deploy a.war
asadmin deploy b.war

By assigning the two war files to a default context root, instead of '/', both will deploy.

If the server assigned 'undefined' apps to '/', the second app would not deploy.
Comment 11 Petr Jiricka 2009-09-25 19:57:54 UTC
> There is a way to specify the root context... 
>  <context-root>/</context-root>

That's good to hear, although it did not work well for me today in b65.

> The IDE does not let us enter '/' in the text field that would become that value...

Which is consistent with the "context path" description in section 3.5 of the servlet 3.0 spec. The project properties
dialog uses the convention set forth by the spec. sun-web.xml uses a different convention, which is fine - but there
should be some mechanism which translates between the two ways. I would suggest that upon receiving "" from the project,
the plugin should just write "/" to sun-web.xml. Analogously for returning the value - when the project asks for context
root value, and sun-web.xml contains "/", the plugin should return "". (Currently it returns "/", which is then
displayed in project properties - which is a bug.) Would this work?

Comment 12 Vince Kraemer 2009-09-26 17:17:04 UTC
thanks for the clarification on the 'meaning' of the field in the property dialog.  I know I never made that connection
while working in that area of the plugin.
Comment 13 Nitya Doraisamy 2009-09-26 17:48:11 UTC
> I would suggest that upon receiving "" from the project, the plugin should just write "/" to sun-web.xml. 
> Analogously for returning the value - when the project asks for contextroot value, and sun-web.xml contains "/"
> the plugin should return "". 

This would work but may cause some confusion. Since generally for non-null values, the sun-web.xml context-root reflects
that provided in the project properties. 
Also, in this scenario, wouldn't the user need to be explicitly prevented from entering empty context root in the
sun-web.xml editor? 

I have corrected the original fix wherein the deploy command handles passing in "/" so v3 will deploy the webapp at root
context. 
Comment 14 Quality Engineering 2009-09-26 21:07:04 UTC
Integrated into 'main-golden', will be available in build *200909251401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/90d0d3d8570e
User: nityad@netbeans.org
Log: #170248 : Fix for webapp with empty context path to deploy to root context
Comment 15 Quality Engineering 2009-09-27 22:34:51 UTC
Integrated into 'main-golden', will be available in build *200909270201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/079099229773
User: nityad@netbeans.org
Log: #170248 : Handle webapp with empty context path
Comment 16 Nitya Doraisamy 2009-09-29 17:45:15 UTC
Fixed, tested nightly 0927
Created webapp with empty context path. sun-web.xml has empty context root element <context-root/>
On deploy, webapp is now deployed to root context
Comment 17 Petr Jiricka 2009-09-30 09:58:35 UTC
Thanks, works fine for me now. Though I still think the behavior is not ideal - I filed a new issue 173356 (P3) and
issue 173359 (P4).