Tomcat配置帮助:多个端口没有响应

发布于 2024-10-12 05:32:08 字数 6569 浏览 4 评论 0原文

我的目标是让端口 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: 生命周期异常:错误 初始化: 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 确实 不存在或不可读 目录»

My goal is to have port 80 and 81 listen and serve content from two distinct paths. I'm looking at replicating what I used to do with IIS and creating websites on specific ports.

I took the base configuration file and added the following lines inside the Server tag (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>

I was going on a tip where I had to install a Service tag with Connector and Context tag for each port I wanted to run (inside the main Server tag).

I looked at my log and found the following:

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)

I am aware about the Context working better in a the more localized context.xml file, but I don't mind restarting until I get this working. Or maybe it NEEDS to be there (not per APress Pro Apache TomCat6).

At this point, going to IP:80 doesn't bring up nothing, no file, no error, just a blank page. Even when I try to access index.html (that was copied in the proper docBase), I get a blank screen without any errors.

Edit #2

I figured I'd post my files in case someone had more time on their hands and wanted a go at them.

Here's my server.xml file:
http://pastebin.com/DAunTPTg

Here's the error I'm getting at the moment:
http://pastebin.com/mrrd0116

Edit #3

To make things simpler, I've tried to have port 80 respond properly.

As per my book:

The name of this virtual host, as
configured with DNS. One of the
hosts nested within an engine must
have a name that matches the
defaultHost attribute of that engine.

Why would I be indicating anything but localhost (localhost1 wouldn't work would it?)

This is where I am at now, still not working:

<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>

I'm also getting a new errors:

18-Jan-2011 8:37:12 PM
org.apache.catalina.startup.Catalina
start SEVERE: Catalina.start:
LifecycleException: Error
initializaing :
java.lang.NullPointerException at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4380)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at
org.apache.catalina.core.StandardService.start(StandardService.java:519)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

and

18-Jan-2011 8:36:47 PM
org.apache.catalina.mbeans.ServerLifecycleListener
createMBeans SEVERE: createMBeans:
Throwable
java.lang.NullPointerException at
org.apache.catalina.mbeans.MBeanUtils.createObjectName(MBeanUtils.java:1086)
at
org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:504)
at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:570)
at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:366)
at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:535)
at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:498)
at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:656)
at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:628)
at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:278)
at
org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLifecycleListener.java:129)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:703)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Edit #4

I added the folder structure /Stable/localhost under the conf folder. Also added both host-manager.xml and manager.xml.

Still doesn't work.

Edit #5

I think I got it, well, I'm serving html and cfml pages with some errors in the log files.

<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>

Errors:

18-Jan-2011 11:31:40 PM
org.apache.catalina.core.StandardContext
resourcesStart SEVERE: Error starting
static Resources
java.lang.IllegalArgumentException:
Document base
C:\websites\test\stable\manager does
not exist or is not a readable
directory»

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自我难过 2024-10-19 05:32:08

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

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

<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/[电子邮件受保护]< /span>/msg44729.html

I think you're on the right track, but you're just missing some of the child elements that are listed in the specification for the Service element.

I think you're just forgetting the Engine and Host elements, which are grandparent and parent respectively to the Context element.

<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>

For more information and a more detailed example, which defines two Service elements, one on port 8080 and one on port 9080, see this mailing list post:

http://www.mail-archive.com/[email protected]/msg44729.html

指尖上得阳光 2024-10-19 05:32:08

这对我有用:

<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>

This is working for me:

<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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文