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.
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.
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
Workaround is: change context path in context.xml/sub-web.xml and Restart IDE.
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.
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.
I can fix the problem in web/project an tomcat but need evaluation from Ludo.
For AS 8.1, the "empty context path" is already used and cannot be used for other web apps. I think.
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.
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!
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.
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).
Yes, the empty string should be allowed. Sorry for confusion.
fixed in trunk
Created attachment 21551 [details] diff
Verified by QE in 200504111800 build.
I agree with the fix.
Merged to 4.1 branch.
Verified in 4.1 build 200504142205.