You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2011/02/08 17:15:03 UTC

DO NOT REPLY [Bug 50734] New: 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

           Summary: 400 Bad Request when there are no web applications
                    deployed on Tomcat 6.0.32
           Product: Tomcat 6
           Version: 6.0.32
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: violetagg@apache.org


Hi,

I have the following use case:
I have no web applications deployed on Tomcat. 
Nevertheless when I request a web application: http://localhost:8080/testapp
Instead of the expected 404 Not Found I'm receiving 400 Bad Request.

This scenario is tested on 6.0.32 and 7.0.8, it is working as expected on
7.0.8.

While searching the code for both versions, I can see that in 7.0.8 you have
the following:

org.apache.catalina.connector.CoyoteAdapter.postParseRequest(Request, Request,
Response, Response)
...
            // If there is no context at this point, it is likely no ROOT
context
            // has been deployed
            if (request.getContext() == null) {
                res.setStatus(404);
                res.setMessage("Not found");
                // No context, so use host
                request.getHost().logAccess(request, response, 0, true);
                return false;
            }
...

In the 6.0.32 version of the same class there is no such statement. When
entering org.apache.catalina.core.StandardEngineValve.invoke(Request, Response)
...
        if (host == null) {
            response.sendError
                (HttpServletResponse.SC_BAD_REQUEST,
                 sm.getString("standardEngine.noHost", 
                              request.getServerName()));
            return;
        }

...

the host is null because the context is null. So 400 Bad Request is returned.

Could you please introduce the check from Tomcat 7.0.8 in Tomcat 6.0.x. I think
that 404 Not Found is more appropriate for this use case and not 400 Bad
Request. The 400 status code typically is returned in case the request cannot
be fulfilled due to bad syntax.

Thanks in advance
Best Regards
Violeta Georgieva

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

--- Comment #1 from Christopher Schultz <ch...@christopherschultz.net> 2011-02-08 15:47:58 EST ---
For more context:

http://markmail.org/message/3tpkhfqrsblzyiwd

In that thread, Pid offhandedly mentions a suggestion from Tim (maybe?) that a
default ROOT context with no content be created if none is already deployed:
this would allow standard "not found" pages to be returned, etc.

Violeta, could you be specific about which patch for 7.0.8 you mean?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

--- Comment #3 from Mark Thomas <ma...@apache.org> 2011-02-11 11:15:18 EST ---
Thanks for the patch. I have proposed it for 6.0.x

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

jfclere <jf...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |akostadinov@gmail.com

--- Comment #5 from jfclere <jf...@gmail.com> 2011-04-26 04:18:43 EDT ---
*** Bug 51116 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

--- Comment #2 from violetagg@apache.org 2011-02-09 04:42:50 EST ---
Created an attachment (id=26626)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26626)
400 Bad Request issue - patch proposal

Hi,
Patch is made based on Tomcat 6.0.32 sources.
Regards
Violeta

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from Mark Thomas <ma...@apache.org> 2011-02-15 12:57:48 EST ---
The patch has been applied to 6.0.x and will be included in 6.0.33 onwards.

Thanks again.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Konstantin Kolinko <kn...@gmail.com> 2011-09-09 18:45:42 UTC ---
(In reply to comment #6)
> This patch has a side effect in my configuration that uses some technical
> valves that will no longer be called if a context does not exist for the
> requested URL (for example, my valve was able to report how many requests
> failed due to invalid context mapping indicating some kind of hacking or
> misconfiguration going on).

1. There is a number of other ways how a request can fail. AccessLogValve
support was improved in 6.0.30. You may find all places in the code where
access logging is triggered.

Anyway, you do not provide much details, and I do not see why this use case may
be of any importance.

If you want to provide more details, open a new issue. This one is fixed.

> 
> As a workaround, i had to declare a dummy ROOT context (pointing to an empty
> directory) so that the v
> 

2. This is a valid workaround. I do not see any problem with it. In essence,
any sane Tomcat installation must have a ROOT webapp.

> I can understand we want to report a 404 but i consider patch should be plugged

I do not quite understand your proposal. I'd be better if you could provide a
patch to illustrate it.

> where 400 is reported (not so early) to report 404 only if no host is matching.

Re-closing as FIXED.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

Chris <ch...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |

--- Comment #6 from Chris <ch...@gmail.com> 2011-09-09 14:06:05 UTC ---
This patch has a side effect in my configuration that uses some technical
valves that will no longer be called if a context does not exist for the
requested URL (for example, my valve was able to report how many requests
failed due to invalid context mapping indicating some kind of hacking or
misconfiguration going on).

As a workaround, i had to declare a dummy ROOT context (pointing to an empty
directory) so that the v

I can understand we want to report a 404 but i consider patch should be plugged
where 400 is reported (not so early) to report 404 only if no host is matching.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50734] 400 Bad Request when there are no web applications deployed on Tomcat 6.0.32

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

violetagg@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |violetagg@apache.org

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org