【问题标题】:Tomcat configuration help: multiple ports not respondingTomcat配置帮助:多个端口无响应
【发布时间】:2011-06-10 19:34:09
【问题描述】:

我的目标是让端口 80 和 81 监听并提供来自两个不同路径的内容。我正在考虑复制我过去使用 IIS 所做的工作,并在特定端口上创建网站。

我获取了基本配置文件,并在服务器标签 (server.xml) 中添加了以下几行:

<Service name="stable">
    <Connector port="80" protocol="HTTP/1.1" />
    <Context docBase="C:\websites\test\stable\" />
  </Service>
  <Service name="release">
    <Connector port="81" protocol="HTTP/1.1" />
    <Context docBase="C:\websites\test\release\" />
  </Service>

我正在提示我必须为每个要运行的端口(在主服务器标签内)安装一个带有连接器和上下文标签的服务标签。

我查看了我的日志,发现以下内容:

16-Jan-2011 8:54:44 AM org.apache.catalina.connector.CoyoteAdapter service
SEVERE: An exception or error occurred in the container during the request processing
java.lang.NullPointerException
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
    at java.lang.Thread.run(Thread.java:619)

我知道 Context 在更本地化的 context.xml 文件中工作得更好,但我不介意重新启动,直到我得到这个工作。或者它可能需要在那里(不是每个 APress Pro Apache TomCat6)。

此时,转到 IP:80 并没有显示任何内容,没有文件,没有错误,只是一个空白页面。即使我尝试访问 index.html(在正确的 docBase 中复制),我也得到一个没有任何错误的空白屏幕。

编辑#2

我想我会发布我的文件,以防有人有更多的时间并想尝试一下。

这是我的 server.xml 文件: http://pastebin.com/DAunTPTg

这是我目前遇到的错误: http://pastebin.com/mrrd0116

编辑#3

为了简单起见,我尝试让端口 80 正确响应。

根据我的书:

此虚拟主机的名称,如 配置了 DNS。中的一个 嵌套在引擎中的主机必须 有一个匹配的名称 该引擎的 defaultHost 属性。

为什么我会指示除 localhost 以外的任何内容(localhost1 不会工作吗?)

这是我现在的位置,仍然无法工作:

<Service name="Stable">
        <Connector 
            port="80" 
            protocol="HTTP/1.1"                
            connectionTimeout="20000" />

        <Engine name="Stable" defaultHost="localhost">
            <Host 
                name="localhost"  
                appBase="webapps">

                <Context docBase="C:\websites\test\stable" />               
            </Host>
        </Engine>
  </Service>

我也收到一个新错误:

2011 年 1 月 18 日晚上 8:37:12 org.apache.catalina.startup.Catalina 开始严重:Catalina.start: LifecycleException:错误 初始化: java.lang.NullPointerException 在 org.apache.catalina.core.StandardContext.start(StandardContext.java:4380) 在 org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 在 org.apache.catalina.core.StandardHost.start(StandardHost.java:785) 在 org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 在 org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) 在 org.apache.catalina.core.StandardService.start(StandardService.java:519) 在 org.apache.catalina.core.StandardServer.start(StandardServer.java:710) 在 org.apache.catalina.startup.Catalina.start(Catalina.java:581) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) 在 org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

2011 年 1 月 18 日晚上 8:36:47 org.apache.catalina.mbeans.ServerLifecycleListener createMBeans 严重:createMBeans: 可投掷的 java.lang.NullPointerException 在 org.apache.catalina.mbeans.MBeanUtils.createObjectName(MBeanUtils.java:1086) 在 org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:504) 在 org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:570) 在 org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:366) 在 org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:535) 在 org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:498) 在 org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:656) 在 org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:628) 在 org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:278) 在 org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLifecycleListener.java:129) 在 org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 在 org.apache.catalina.core.StandardServer.start(StandardServer.java:703) 在 org.apache.catalina.startup.Catalina.start(Catalina.java:581) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) 在 org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

编辑#4

我在conf文件夹下添加了文件夹结构/Stable/localhost。还添加了 host-manager.xml 和 manager.xml。

还是不行。

编辑#5

我想我明白了,我正在提供 html 和 cfml 页面,但日志文件中有一些错误。

<Service name="Stable">
        <Connector 
            port="80" 
            protocol="HTTP/1.1"                
            connectionTimeout="20000" />

        <Engine name="Stable" defaultHost="localhost">
            <Host 
                name="localhost"  
                appBase="C:\websites\test\stable\">

                <Context docBase="C:\websites\test\stable\" path="" />              
            </Host>
        </Engine>
  </Service>

错误:

2011 年 1 月 18 日晚上 11:31:40 org.apache.catalina.core.StandardContext resourcesStart 严重:启动错误 静态资源 java.lang.IllegalArgumentException: 文档库 C:\websites\test\stable\manager 确实 不存在或不可读 目录»

【问题讨论】:

    标签: tomcat configuration ports railo


    【解决方案1】:

    我认为您在正确的轨道上,但您只是缺少一些在 Service 元素规范中列出的子元素。

    我认为您只是忘记了 EngineHost 元素,它们分别是 Context 元素的祖父母和父母。 p>

    <Service name="stable">
    
         <Connector port="80" protocol="HTTP/1.1" 
               maxThreads="150" connectionTimeout="20000"/>
    
         <Engine name="stable" defaultHost="localhost">
             <Host name="localhost1" appBase="webapp1">
                 <Context docBase="C:\websites\test\stable\" />
            </Host>
         </Engine>
    
    </Service>
    
    
    <Service name="release">
    
        <Connector port="81" protocol="HTTP/1.1" 
               maxThreads="150" connectionTimeout="20000"/>
    
        <Engine name="release" defaultHost="localhost2">
             <Host name="localhost2" appBase="webapp2">
                 <Context docBase="C:\websites\test\release\" />
             </Host>
         </Engine>
    
    </Service>
    

    有关更多信息和更详细的示例,它定义了两个服务元素,一个在端口 8080 上,一个在端口 9080 上,请参阅此邮件列表帖子:

    http://www.mail-archive.com/users@tomcat.apache.org/msg44729.html

    【讨论】:

    • @jmort252:谢谢!到目前为止,我遇到了一个不同的错误。如果我不能让它工作,将尝试调试和发布。我也会查看您发布的链接。
    【解决方案2】:

    这对我有用:

    <Service name="Stable">
        <Connector 
            port="80" 
            protocol="HTTP/1.1"                
            connectionTimeout="20000" />
    
        <Engine name="Stable" defaultHost="localhost">
            <Host 
                name="localhost"  
                appBase="C:\websites\test\stable\">
    
                <Context docBase="C:\websites\test\stable\" path="" />              
            </Host>
        </Engine>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 2018-04-16
      • 2013-02-07
      • 2020-09-15
      • 2013-08-29
      • 2011-05-20
      相关资源
      最近更新 更多