I have already got it work.
Thank you.

Regards,
Chatree Srichart

On Tue, Nov 22, 2011 at 2:17 PM, Konstantin Kolinko
<knst.koli...@gmail.com>wrote:

> Confirming that it is a bug. I filed an issue:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=52225
>
>
> You would avoid this bug if you reorder your lines:
> call "host.addAlias()" before you call "engine.addChild()".
>
> That is what Digester does when parsing server.xml:
> "engine.addChild()" method is called on the closing "</Host>" tag.
>
> Best regards,
> Konstantin Kolinko
>
> 2011/11/22 Chatree Srichart <chatree.srich...@gmail.com>:
> > Any comment?
> >
> > On Mon, Nov 21, 2011 at 1:52 PM, Chatree Srichart <
> > chatree.srich...@gmail.com> wrote:
> >
> >> 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?
> >>
> >> Regards,
> >> Chatree Srichart
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

Reply via email to