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 57676 - WP properties does not save empty string context path
Summary: WP properties does not save empty string context path
Status: CLOSED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: Pavel Buzek
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2005-04-08 14:55 UTC by Sherold Dev
Modified: 2006-03-24 13:06 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
diff (1.51 KB, text/plain)
2005-04-11 16:44 UTC, Pavel Buzek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sherold Dev 2005-04-08 14:55:43 UTC
Web project properties does not save empty string context path. 
 
A workaround is to set the context path directly in the context.xml or 
sun-web.xml.
Comment 1 zikmund 2005-04-08 15:31:05 UTC
Workaround doesn't work => raising priority to P2:

1) Edit context.xml to empty ("") ontext path
2) Open project's Properties | Run
3) Context path is empty (it's OK), Press OK
4) Open project's Properties | Run
5) ERROR:
There's again "/yourcontext" in Context Path
Comment 2 zikmund 2005-04-08 15:47:45 UTC
Workaround is: change context path in context.xml/sub-web.xml and Restart IDE.
Comment 3 Pavel Buzek 2005-04-08 17:13:39 UTC
What leads you to think that empty context path is valid?

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/manager-howto.html
# Invalid context path was specified
    The context path must start with a slash character. To reference the ROOT
web application use "/".

In 5.5.4 archive in documentation I see:
# Invalid context path was specified
    The context path must start with a slash character, unless you are
    referencing the ROOT web application -- in which case the context path
    must be a zero-length string.

This is in documentation, but I think that the documentation is wrong!!

In source code (ManagerServlet) I see:
        // Validate the requested context path
        if ((path == null) || path.length() == 0 || !path.startsWith("/")) {
            writer.println(sm.getString("managerServlet.invalidPath", path));
            return;
        }
(the same code is in 5.0.30, 5.0.28, 5.5.4, 5.5.7, even in 4.1.27)
When I disable the checks for empty path in netbeans, sure enough I get:
Deployment FAILED: FAIL - Invalid context path  was specified
(note the 2 spaces between "path" a "was" where the empty path is clearly
printed - you do not see it? :-).

In 4.0.1 sources you have:
        if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
            writer.println(sm.getString("managerServlet.invalidPath", path));
            return;
        }
Looks like this will let go a path like "foo". But we do not support 4.x anyway.
Comment 4 Pavel Buzek 2005-04-08 17:36:53 UTC
In fact the problem is in neither web project nor tomcat allowing "/" as the
context path. If you set this in context.xml using xml editor the module is
deployed to tomcat w/o problems.

The app server will appload web module with context path "/", but will set the
context to a strange value (like "upload-1__308356087") and the browser is open
at http://129.150.25.108:8087// which shows a front page of server, not the web
module.
Comment 5 Pavel Buzek 2005-04-08 17:38:20 UTC
I can fix the problem in web/project an tomcat but need evaluation from Ludo.
Comment 6 _ ludo 2005-04-08 18:11:27 UTC
For AS 8.1, the "empty context path" is already used and cannot be used for
other web apps. I think.

Comment 7 Pavel Buzek 2005-04-08 18:36:18 UTC
Does it mean I can fix it or not?

As I am saying, app server does deploy a module with context path '/' (or with
an empty contex path) w/o reporting an error, only it deploys it to a strange
context.
Currently the app server editor allows both an empty string and '/' for context
path, but it silently converts '/' to an empty string (which is a bug by itself).

Since context path is not part of specification for it can be set differently
for different servers. I think that servers should apply restrictions but we
should relax the restrictions in web project properties dialog to allow what
works for various servers.

Unless you object I am going to fix this for tomcat and web/project.
Comment 8 Sherold Dev 2005-04-08 21:15:18 UTC
According to what the j2ee spec says: 
 
"If this context is the "default" context rooted at the base of 
the Web server's URL name space, this path will be an empty string. 
Otherwise, if the context is not rooted at the root of the server's 
name space, the path starts with a'/' character but does not end with 
a'/' character." 
 
This was previously discussed in the issue 40126. 
 
Tomcat Manager, however, uses "/" instead of "" for the ROOT context path. 
This was workarounded sofar in the tomcat plugin by replacing the "" context 
path with the "/". Unfortunately, this currently doesn't work, but it is an 
easy fix. 
 
I have to emphasize that this "" vs "/" issue is a bug in TOMCAT MANAGER ONLY. 
The correct value in the context.xml is in accord with spec which is "". 
If the context.xml contains "/" instead of "", it will not be possible to 
undeploy such a web application! 
 
Pavel, we should keep those strict restrictions on the context path in the 
exact form as we had sofar! 
Comment 9 Petr Jiricka 2005-04-11 12:17:09 UTC
I agree with Stepan - context path is NOT server specific, its syntax is
dictated by the specification and we should inforce that. This is also important
for correctly generating application.xml in EAR project.
If a particular server uses a different syntax for its specific files, then the
plugin for this server should be responsible for making any necessary conversions.
If appserver does not allow the use of empty path, then this should be reported
by the appserver plugin.
Comment 10 Pavel Buzek 2005-04-11 13:58:19 UTC
Stepane, Petre, thanks for correcting me.

> Pavel, we should keep those strict restrictions on the context path in the 
> exact form as we had sofar! 

I assume you mean the exact restriction _except_ allowing to enter an empty
string (which the currect restrictions do not allow).
Comment 11 Sherold Dev 2005-04-11 14:47:16 UTC
Yes, the empty string should be allowed. Sorry for confusion.
Comment 12 Pavel Buzek 2005-04-11 16:43:54 UTC
fixed in trunk
Comment 13 Pavel Buzek 2005-04-11 16:44:35 UTC
Created attachment 21551 [details]
diff
Comment 14 zikmund 2005-04-12 15:51:03 UTC
Verified by QE in 200504111800 build.
Comment 15 Sherold Dev 2005-04-12 17:29:07 UTC
I agree with the fix.
Comment 16 Pavel Buzek 2005-04-14 19:13:56 UTC
Merged to 4.1 branch. 
Comment 17 zikmund 2005-04-15 17:52:07 UTC
Verified in 4.1 build 200504142205.