ubuntu 14.04.1上的Apache tomcat7因部署战争而获得404错误,而管理员获得401错误

时间:2015-05-12 20:07:16

标签: java apache tomcat ubuntu war

我在ubuntu服务器上的tomcat7上部署了war。我成功获得了tomcat7主页,点击了ip:8080链接。

如果这进一步有帮助,我按照给定here的步骤进行了操作。

sudo apt-get update
sudo apt-get install tomcat7

所以现在tomcat7作为服务安装。 为了部署war,我只是停止了tomcat,然后将myapp.war文件放在webapps目录中。然后我启动了tomcat服务器。 catalina的日志显示了这些(跳过不必要的行):

INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
May 12, 2015 3:44:01 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/myapp.war
May 12, 2015 3:44:18 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined

当我尝试访问ip:8080 / myapp url时,这给我404错误。

然后我尝试为apache下载windows二进制文件,然后在webapps中放置war,然后在另一台Windows机器上放置startup.bat。这完美地工作(因此证明war文件和/或其web.xml没有任何问题)。但只有在linux上才会出现404问题。我看到所有与类似问题相关的答案,其中大多数建议访问经理应用程序。所以我使用sudo apt-get安装了经理应用程序。它安装成功。但不幸的是,它在ip:8080 / manager上显示了用户名和密码字段。 这需要修改tomcat-users.xml文件,这就是我的样子:

<?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.
-->
<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary.
-->
<!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->
  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user name="tomcat" password="s3cret" roles="standard,manager-gui,admin-gui,tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>

</tomcat-users>

我尝试输入tomcat7和s3cret作为凭据,但是这不会被接受,并且再次弹出询问用户名和密码的框。我不知道为什么会发生这种情况。我的结局似乎没有什么不对,因为这是安装tomcat和部署war文件的方式(这不是我第一次这样做),它也适用于我。

请有人提供解决方法。

0 个答案:

没有答案