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 (chat@gmail.com)
Date:Nov 20, 2011 10:52:28 pm
List:org.apache.tomcat.dev

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.

host.addAlias("localhost2");

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(Request.java:631) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:105) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)

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

Index: java/org/apache/tomcat/util/http/mapper/Mapper.java =================================================================== --- java/org/apache/tomcat/util/http/mapper/Mapper.java (revision 1204361) +++ java/org/apache/tomcat/util/http/mapper/Mapper.java (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?