改端口号为80后,路径也改成/为什么报404错误啦?

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

7回答
提问者 浮生Y一梦 2019-04-15 12:39:09

Eclipse控制台输出结果:

严重: Failed to initialize connector [Connector[HTTP/1.1-80]]

org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-80]]

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)

at org.apache.catalina.core.StandardService.initInternal(StandardService.java:552)

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)

at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:875)

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)

at org.apache.catalina.startup.Catalina.load(Catalina.java:639)

at org.apache.catalina.startup.Catalina.load(Catalina.java:662)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:309)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)

Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed

at org.apache.catalina.connector.Connector.initInternal(Connector.java:995)

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)

... 12 more

Caused by: java.net.BindException: Address already in use: bind

at sun.nio.ch.Net.bind0(Native Method)

at sun.nio.ch.Net.bind(Unknown Source)

at sun.nio.ch.Net.bind(Unknown Source)

at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)

at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)

at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:219)

at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1105)

at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:224)

at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:581)

at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:68)

at org.apache.catalina.connector.Connector.initInternal(Connector.java:993)

... 13 more


  • 报错信息是指这个端口号被占用了。建议同学把端口号都还成8080试试。祝学习愉快。
    2019-04-15 17:19:01
  • 提问者 浮生Y一梦 回复 好帮手慕阿莹 #2
    老师,只要不改端口号,不管是在eclipse里面发布还是在导出后发布都是正常的。我应该怎么该端口号呢?
    2019-04-15 21:21:14
  • 慕布斯37364 回复 提问者 浮生Y一梦 #3
    你这个有可能是80端口号被占用了 https://jingyan.baidu.com/article/3c48dd34491d47e10be358b8.html ,你可以看看是哪个程序占用了,如果不是必须的,先关掉这个程序。然后再用80的端口号去试试这个程序
    2019-04-16 15:56:40
提问者 浮生Y一梦 2019-04-15 08:54:21

http://img1.sycdn.imooc.com//climg/5cb3d61b000159b708930654.jpg

http://img1.sycdn.imooc.com//climg/5cb3d61b00016e9b07820599.jpg

使用eclipse发布也报错


  • 同学你好。你使用stratup.bat是否会闪退呢?截图一下双击stratup.bat后弹出的窗口吧
    2019-04-16 10:14:52
  • 提问者 浮生Y一梦 回复 芝芝兰兰 #2
    报错信息是指这个端口号被占用了,我只要不改端口号就不会报错。startup.bat不会闪退
    2019-04-16 10:24:13
芝芝兰兰 2019-04-14 17:10:31

同学你好。请问同学在设置完server.xml后是使用Eclipse将项目发布的?还是和老师在视频中的一样,将war包放在了webapps下,直接使用startup.bat将Tomcat启动发布的?如果还是使用的Eclipse,那么同学的docBase需要改成项目名。

<Context docBase="request_struc" path="/" reloadable="true" source="org.eclipse.jst.jee.server:request_struc"/>

如果解答了同学的疑问,望采纳~

祝学习愉快~


  • 提问者 浮生Y一梦 #1
    使用的老师那种发布方式
    2019-04-14 17:16:03
  • 提问者 浮生Y一梦 #2
    我先修改端口号也报错404错误
    2019-04-14 17:17:47
  • 芝芝兰兰 回复 提问者 浮生Y一梦 #3
    是所有的页面都会404吗?
    2019-04-14 18:51:18
提问者 浮生Y一梦 2019-04-13 15:10:08
提问者 浮生Y一梦 2019-04-13 15:06:00
提问者 浮生Y一梦 2019-04-13 15:02:00

<?xml version="1.0" encoding="UTF-8"?>

<!--

  Licensed to the Apache Software Foundation (ASF) under one or more

  contributor license agreements.  See the NOTICE file distributed with

  this work for additional information regarding copyright ownership.

  The ASF licenses this file to You under the Apache License, Version 2.0

  (the "License"); you may not use this file except in compliance with

  the License.  You may obtain a copy of the License at


      http://www.apache.org/licenses/LICENSE-2.0


  Unless required by applicable law or agreed to in writing, software

  distributed under the License is distributed on an "AS IS" BASIS,

  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  See the License for the specific language governing permissions and

  limitations under the License.

--><!-- Note:  A "Server" is not itself a "Container", so you may not

     define subcomponents such as "Valves" at this level.

     Documentation at /docs/config/server.html

 --><Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>

  <!-- Security listener. Documentation at /docs/config/listeners.html

  <Listener className="org.apache.catalina.security.SecurityListener" />

  -->

  <!--APR library loader. Documentation at /docs/apr.html -->

  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>

  <!-- Prevent memory leaks due to use of particular java/javax APIs-->

  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>

  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>


  <!-- Global JNDI resources

       Documentation at /docs/jndi-resources-howto.html

  -->

  <GlobalNamingResources>

    <!-- Editable user database that can also be used by

         UserDatabaseRealm to authenticate users

    -->

    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>

  </GlobalNamingResources>


  <!-- A "Service" is a collection of one or more "Connectors" that share

       a single "Container" Note:  A "Service" is not itself a "Container",

       so you may not define subcomponents such as "Valves" at this level.

       Documentation at /docs/config/service.html

   -->

  <Service name="Catalina">


    <!--The connectors can use a shared executor, you can define one or more named thread pools-->

    <!--

    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"

        maxThreads="150" minSpareThreads="4"/>

    -->



    <!-- A "Connector" represents an endpoint by which requests are received

         and responses are returned. Documentation at :

         Java HTTP Connector: /docs/config/http.html

         Java AJP  Connector: /docs/config/ajp.html

         APR (HTTP/AJP) Connector: /docs/apr.html

         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080

    -->

    <Connector connectionTimeout="20000" port="80" protocol="HTTP/1.1" redirectPort="8443"/>

    <!-- A "Connector" using the shared thread pool-->

    <!--

    <Connector executor="tomcatThreadPool"

               port="8080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />

    -->

    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443

         This connector uses the NIO implementation. The default

         SSLImplementation will depend on the presence of the APR/native

         library and the useOpenSSL attribute of the

         AprLifecycleListener.

         Either JSSE or OpenSSL style configuration may be used regardless of

         the SSLImplementation selected. JSSE style configuration is used below.

    -->

    <!--

    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"

               maxThreads="150" SSLEnabled="true">

        <SSLHostConfig>

            <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"

                         type="RSA" />

        </SSLHostConfig>

    </Connector>

    -->

    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2

         This connector uses the APR/native implementation which always uses

         OpenSSL for TLS.

         Either JSSE or OpenSSL style configuration may be used. OpenSSL style

         configuration is used below.

    -->

    <!--

    <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"

               maxThreads="150" SSLEnabled="true" >

        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />

        <SSLHostConfig>

            <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"

                         certificateFile="conf/localhost-rsa-cert.pem"

                         certificateChainFile="conf/localhost-rsa-chain.pem"

                         type="RSA" />

        </SSLHostConfig>

    </Connector>

    -->


    <!-- Define an AJP 1.3 Connector on port 8009 -->

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>



    <!-- An Engine represents the entry point (within Catalina) that processes

         every request.  The Engine implementation for Tomcat stand alone

         analyzes the HTTP headers included with the request, and passes them

         on to the appropriate Host (virtual host).

         Documentation at /docs/config/engine.html -->


    <!-- You should set jvmRoute to support load-balancing via AJP ie :

    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">

    -->

    <Engine defaultHost="localhost" name="Catalina">


      <!--For clustering, please take a look at documentation at:

          /docs/cluster-howto.html  (simple how to)

          /docs/config/cluster.html (reference documentation) -->

      <!--

      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

      -->


      <!-- Use the LockOutRealm to prevent attempts to guess user passwords

           via a brute-force attack -->

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <!-- This Realm uses the UserDatabase configured in the global JNDI

             resources under the key "UserDatabase".  Any edits

             that are performed against this UserDatabase are immediately

             available for use by the Realm.  -->

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>

      </Realm>


      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">


        <!-- SingleSignOn valve, share authentication between web applications

             Documentation at: /docs/config/valve.html -->

        <!--

        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />

        -->


        <!-- Access log processes all example.

             Documentation at: /docs/config/valve.html

             Note: The pattern used is equivalent to using pattern="common" -->

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log" suffix=".txt"/>


      <Context docBase="E:\apacheTomcat\apache-tomcat-8.5.39\webapps\request_struc" path="/" reloadable="true" source="org.eclipse.jst.jee.server:request_struc"/></Host>

    </Engine>

  </Service>

</Server>


  • 同学你好!你可以尝试着重启一下电脑、eclipse、项目测试一下,也可以重新建个工程进行测试,在测试的过程中建议先测试一下改端口,没有问题,在更改工程名。祝学习愉快~
    2019-04-13 17:34:54
  • 提问者 浮生Y一梦 回复 好帮手慕柯南 #2
    老师,还是不行怎么办
    2019-04-14 12:00:23
好帮手慕柯南 2019-04-13 12:00:07

同学你好!docBase的内容要写项目在tomcat中的路径,要写你自己项目的地址哦~如图所示:

http://img1.sycdn.imooc.com//climg/5cb15e1a0001393d10540085.jpg

如果我的回答解决了你的疑问,请采纳~祝学习愉快!


  • 提问者 浮生Y一梦 #1
    写了也还是报错
    2019-04-13 14:03:56
  • 好帮手慕柯南 回复 提问者 浮生Y一梦 #2
    同学你好!你把配置文件的代码贴完整,不要截图,注意不要贴在回复里,会失去代码的格式。可以用回答这个问题的方式,将代码贴入。运行效果图贴出来,包括url地址,还有项目结构都提供以下。如果我的回答解决了你的疑问,请采纳~祝学习愉快!
    2019-04-13 14:56:16
  • 提问者 浮生Y一梦 回复 好帮手慕柯南 #3
    老师,在帮忙看一下吧
    2019-04-13 15:15:06
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
从网页搭建入门Java Web2018版
  • 参与学习           人
  • 提交作业       1088    份
  • 解答问题       10204    个

如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师