Bug 48381 - Hostnames in the <Host> section are converted to lower case
Summary: Hostnames in the <Host> section are converted to lower case
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 6.0.20
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2009-12-11 12:44 UTC by japel
Modified: 2009-12-13 15:09 UTC (History)
0 users

Webapp for demonstrating the bug (5.59 KB, application/zip)
2009-12-11 12:44 UTC, japel
This patch is for the documentation (use lower case hostnames) (771 bytes, patch)
2009-12-11 12:52 UTC, japel
Details | Diff
Hoastnames are no longer lower case internally (1.20 KB, patch)
2009-12-11 12:56 UTC, japel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description japel 2009-12-11 12:44:32 UTC
Created attachment 24700 [details]
Webapp for demonstrating the bug

If the attribute name in the <Host> configuration contains upper case letters
and you use a case-sensitive file system than the configuration files are
looked up in the wrong directory (hostname converted to lower case)

RFC 1035 (DNS) says in section 2.3.1.:
Note that while upper and lower case letters are allowed in domain
names, no significance is attached to the case.  That is, two names with
the same spelling but different case are to be treated as if identical.

Let us suppose we have this configuration in the server.xml:

<Engine name="Catalina" defaultHost="Tux">

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

      <Host name="Tux"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

The expected behavior is, that the configuration files are searched under
$CATALINA_BASE/conf/[engine_name]/[host_name] which is in our case

Instead Tomcat converts silently Tux to tux and searches under

Steps to reproduce:
1. Configure the server.xml with a hostname which contains upper case letters. See above.
2. Deploy the webapp tomcatbug
   cd webapps
   unzip tomcatbug.zip
   cd tomcatbug
   ant all
3. Create a file $CATALINA_BASE/conf/Catalina/Tux/tomcatbug.xml with this content
    <Resource name="bean/MyBeanFactory" auth="Container"
4. Start tomcat and browse to http://Tux:8080/tomcatbug/TomcatBug

Actual result:
<title>Tomcat Bug</title>
<h1>Tomcat Bug</h1>
javax.naming.NamingException: Cannot create resource instance
    at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:114)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at TomcatBug.doGet(TomcatBug.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)

Expected result:
<title>Tomcat Bug</title>
<h1>Tomcat Bug</h1>
foo = Default Foo, bar = 23

As a workaround you should not use upper case letters in hostnames. 
This should be written in the documentation.
Comment 1 japel 2009-12-11 12:52:16 UTC
Created attachment 24701 [details]
This patch is for the documentation (use lower case hostnames)
Comment 2 japel 2009-12-11 12:56:17 UTC
Created attachment 24702 [details]
Hoastnames are no longer lower case internally

This patch might have several side effects and the core developers 
most likely had their reasons for converting hostnames to lower case internally.
Comment 3 Mark Thomas 2009-12-13 15:09:01 UTC
Treating host names in a case sensitive manner is likely to break things and is not consistent with RFC 1035.

I have updated the docs for trunk, 6.0.x and 5.5.x.