atom feed4 messages in org.apache.tomcat.devMultiple Aliases Problem
FromSent OnAttachments
Chatree SrichartNov 20, 2011 10:52 pm 
Chatree SrichartNov 21, 2011 7:56 pm 
Konstantin KolinkoNov 21, 2011 11:17 pm 
Chatree SrichartNov 22, 2011 1:01 am 
Subject:Multiple Aliases Problem
From:Chatree Srichart (
Date:Nov 20, 2011 10:52:28 pm

Hi community. I am working on embedding a Tomcat server into my project.

I have 2 domain name called localhost1 and localhost2. I created a Host instance with the localhost1 domain name.

Host host = new StandardHost(); host.setAppBase(CATALINA_HOSTS_HOME); host.setName("localhost1"); host.setDeployOnStartup(false); host.setBackgroundProcessorDelay(5); host.setAutoDeploy(false); host.setRealm(engine.getRealm()); engine.addChild(host);

Then I added the localhost2 as a alias.


If I entered localhost1 at a browser then it works fine but if I entered localhost2 at the browser then I got an error:

Nov 21, 2011 1:29:26 PM org.apache.coyote.http11.AbstractHttp11Processor process SEVERE: Error processing request java.lang.ClassCastException: org.apache.tomcat.util.http.mapper.Mapper$Host cannot be cast to org.apache.catalina.Host at org.apache.catalina.connector.Request.getHost( at org.apache.catalina.core.StandardEngineValve.invoke( at org.apache.catalina.valves.AccessLogValve.invoke( at org.apache.catalina.connector.CoyoteAdapter.service( at org.apache.coyote.http11.AbstractHttp11Processor.process( at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process( at$ at java.util.concurrent.ThreadPoolExecutor$Worker.runTask( at java.util.concurrent.ThreadPoolExecutor$ at

I solved this problem by adding some codes into the trunk:

Index: java/org/apache/tomcat/util/http/mapper/ =================================================================== --- java/org/apache/tomcat/util/http/mapper/ (revision 1204361) +++ java/org/apache/tomcat/util/http/mapper/ (working copy) @@ -149,6 +149,10 @@ newHost.contextList = realHost.contextList; newHost.object = realHost; if (insertMap(hosts, newHosts, newHost)) { + Object object = newHost.object; + if (object instanceof Mapper.Host) { + newHost.object = ((Mapper.Host) object).object; + } hosts = newHosts; } }

Do you think I am doing in the right track and this fixed should be committed into the trunk? If not, could you please give me a solution to solve the problem?