首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在同一个tomcat上部署web服务,但在不同的端口上部署web服务

在同一个tomcat上部署web服务,但在不同的端口上部署web服务
EN

Stack Overflow用户
提问于 2012-01-16 07:16:56
回答 1查看 11.3K关注 0票数 3

我已经在struts中开发了web门户,它部署在端口8080上的tomcat中&现在,我想在同一个tomcat服务器上部署web服务,但在不同的端口8090上部署web服务。

C:\tomcat-6.0.32\conf\server.xml:

代码语言:javascript
复制
<?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\webapp\根目录中爆炸。

C:\tomcat-6.0.32\conf\Catalina\localhost\ROOT.xml包含web门户的以下条目:

代码语言:javascript
复制
<?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:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>

<Context path="/" docBase="C:/testing" debug="5" reloadable="false" useHttpOnly="true" crossContext="true">
</Context>

在C:/测试中,我只是放置了abc.htm,看看它是否可以从http://localhost:8090/abc.htm访问,但它没有工作。相反,它显示了C:\tomcat-6.0.32\webapp\根目录中的index.html,当我访问http://localhost:8090 & http://localhost:8080时会产生404错误。

这是我的catalina.log:

代码语言:javascript
复制
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\webapp目录中,可以在http://localhost:8090上访问它,现在有谁可以帮助我解决这个问题,以便将index.html放在其他目录中呢?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2013-09-26 02:36:39

请查收这篇文章

https://personal.ntu.edu.sg/ehchua/programming/howto/Tomcat_More.html

代码语言:javascript
复制
<Service name="reciver">  
                <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="10"   
                           enableLookups="false" acceptCount="100"  
                           connectionTimeout="10000" disableUploadTimeout="true"   
                           useBodyEncodingForURI="true"/>  
                <Engine name="reciver" defaultHost="localhost" jvmRoute="host1">  
                        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
                               resourceName="UserDatabase" />  
                        <Host name="localhost" appBase="webapps" unpackWARs="true"  
                              autoDeploy="false" xmlValidation="false"  
                              xmlNamespaceAware="false">  
                                <Context docBase="browser" path="/browser" reloadable="false"/>  
                        </Host>  
                </Engine>  
        </Service>  
        <Service name="reciver2">  
                <Connector port="8081" maxHttpHeaderSize="8192" maxThreads="10"   
                           enableLookups="false" acceptCount="1"  
                           connectionTimeout="10000" disableUploadTimeout="true"   
                           useBodyEncodingForURI="true" proxyName="example.pt" proxyPort="80"/>  
                <Engine name="reciver2" defaultHost="example_app" jvmRoute="host2">  
                        <Host name="example_app" appBase="test_app/example_app" unpackWARs="true"  
                              autoDeploy="false" xmlValidation="false"  
                              xmlNamespaceAware="false">  
                                <Context docBase="example_app" path="/example_app" reloadable="false"/>  
                        </Host>  
                </Engine>  
</Service>  
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8876805

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档