问题排查:The requested URL /test/index.jsp was not found on this server

问题描述

添加一个新模块,部署在服务器上。服务器上还部署有其他模块且访问正常,新模块和其他模块共用同一个域名。服务部署之后,请求如下:
http://my.domain.com/test/index.jsp
返回

Not Found

The requested URL /test/index.jsp was not found on this server.

解决步骤

  • 登入服务器,查看tomcat的webapp目录下,发现有test目录和/test/index.jsp文件。
  • 查看/tomcat/conf/server.xml中connector的配置:
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
  • 本地访问尝试:

http://localhost:8080/test/index.jsp 正常
http://localhost:80/test/index.jsp Not Found
http://my.domain.com:8080/test/index.jsp 正常
http://my.domain.com:80/test/index.jsp Not Found
得出结论,端口号与模块匹配有限制。

  • http服务使用的是apache,网上搜索关于apache多端口多目录的配置方法。找到配置文件后参照之前模块的格式进行配置。
  • /cong/httpd.conf 文件中,确保这句Include conf/extra/httpd-vhosts.conf没有被注释掉。
  • 然后打开/conf/extra/httpd-vhosts.conf 文件查看配置,参照之前的配置,如下:
 <VirtualHost *:80>
    ServerName my.domain.com
    ProxyRequests Off

    <Location /test>
       ProxyPass balancer://test/
       ProxyPassReverse balancer://test/
    </Location>

    <Proxy balancer://test>
        Order Deny,Allow
        Allow from all
        BalancerMember http://127.0.0.1:8080/test
        ProxySet lbmethod=byrequests
    </Proxy>
</VirtualHost>
  • 重启apache服务器

./apachectl restart
返回:
httpd not running, trying to start
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

命令: sudo ./apachectl restart
返回:
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

命令:sudo killall httpd
sudo:killall:找不到命令

ps axu| grep httpd
sudo kill -9 365 355 367 383 398 //删除这些httpd进程
sudo ./apachectl start 启动成功

原文地址:https://www.cnblogs.com/shoren/p/java-tomcat-apache.html