【发布时间】:2012-01-16 07:16:56
【问题描述】:
我在 struts 中开发了一个门户网站,该门户网站部署在 tomcat 的 8080 端口上,现在我想在同一个 tomcat 服务器上部署 web 服务,但在不同的端口 8090 上。
C:\tomcat-6.0.32\conf\server.xml:
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
<Service name="testing">
<Connector port="8090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="9443" />
<Connector port="8092" protocol="AJP/1.3" redirectPort="9443" />
<Engine name="testing" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
在这里,我为 Web 服务添加了带有名称测试的新服务条目,以将其部署在 8090 上。 门户的war文件在C:\tomcat-6.0.32\webapps\ROOT目录下展开。
C:\tomcat-6.0.32\conf\Catalina\localhost\ROOT.xml 包含以下门户网站条目:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/" docBase="" debug="5" reloadable="false" useHttpOnly="true" crossContext="true">
</Context>
现在,对于 Web 服务,我创建了 C:\tomcat-6.0.32\conf\testing\localhost\testing.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/" docBase="C:/testing" debug="5" reloadable="false" useHttpOnly="true" crossContext="true">
</Context>
在 C:/testing 中,我只是放置了 abc.htm 以查看是否可以从 http://localhost:8090/abc.htm 访问它,但它不起作用。相反,当我访问 http://localhost:8090 和 http://localhost:8080 时,它会显示 C:\tomcat-6.0.32\webapps\ROOT 目录中的 index.html 给出 404 错误。
这是我的 catalina.log:
INFO: Deploying configuration descriptor ROOT.xml
Jan 15, 2012 11:16:25 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 15, 2012 11:16:25 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 15, 2012 11:16:25 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/19 config=null
Jan 15, 2012 11:16:25 PM org.apache.catalina.core.StandardService start
INFO: Starting service testing
Jan 15, 2012 11:16:25 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
Jan 15, 2012 11:16:25 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor testing.xml
Jan 15, 2012 11:16:25 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Jan 15, 2012 11:16:25 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8090
Jan 15, 2012 11:16:25 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8092
Jan 15, 2012 11:16:25 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
Jan 15, 2012 11:16:25 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 510 ms
谁能告诉我怎么回事?
更新:我刚刚注意到,如果我将 index.html 放在 C:\tomcat-6.0.32\webapps 目录中,则可以通过http://localhost:8090 访问它,现在谁能帮我解决这个问题,以便我想要将 index.html 放在其他目录中?
谢谢!
【问题讨论】:
-
也许这会有所帮助:wiki.apache.org/tomcat/…
-
它不能解决我原来的问题。我认为我的基本上下文路径不正确。但不知道如何解决它......