2012-03-30 152 views
10

我有一个tomcat7。访问管理器应用程序(http:// localhost:7777/manager/html)可以正常使用tomcat-users.xml中定义的凭据。maven tomcat7:部署失败,访问被拒绝

现在我想用maven3部署一个应用程序。我配置tomcat的Maven插件:

<plugin> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <version>2.0-beta-1</version> 
    <configuration> 
     <url>http://localhost:7777/manager</url> 
     <server>localhost7777</server> 
    </configuration> 
</plugin> 
<plugin> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat6-maven-plugin</artifactId> 
    <version>2.0-beta-1</version> 
    <configuration> 
     <url>http://localhost:7777/manager</url> 
     <server>localhost7777</server> 
    </configuration> 
</plugin> 

在内行Setting.xml的我增加了对服务器的条目:

<servers> 
    <server> 
     <id>localhost7777</id> 
     <username>manager</username> 
     <password>secret</password> 
    </server> 
</servers> 

现在,应用程序将被打造成功。但我们的目标tomcat7:从Tomcat部署导致一个拒绝访问的错误消息:

... 
[INFO] Deploying war to http://localhost:7777/workload-monitor 
Uploading: http://localhost:7777/manager/deploy?path=%2Fworkload-monitor&update=true 
Uploaded: http://localhost:7777/manager/deploy?path=%2Fworkload-monitor&update=true (2329 KB at 55435.1 KB/sec) 

[INFO] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
[INFO] <html> 
[INFO] <head> 
[INFO] <title>403 Access Denied</title> 
[INFO] <style type="text/css"> 
[INFO]  <!-- 
... 

可能有人给我一个提示?

+0

哪一个是正确的? tomcat6-或tomcat7-? – khmarbaise 2012-03-30 10:43:02

+0

两者都必须在pom.xml中定义,因为有些目标仅在tomcat6 mojo中可用(请参阅http://tomcat.apache.org/maven-plugin-2/index.html)。 – magomi 2012-03-30 10:50:38

+1

首先让它运行在只有tomcat7的情况下,但不能同时运行。之后,您需要考虑其他目标的配置文件。 – khmarbaise 2012-03-30 11:13:57

回答

1

尽管不是问题的答案,但问题似乎是由于tomcat:deploy尝试将webapp部署到http://localhost:7777/manager/deploy而tomcat7部署url为http://localhost:777/manager/html/deploy。似乎没有办法将其指定为插件配置。

3

http://mycodenotes.wordpress.com/2011/01/25/mvn-tomcatdeploy-to-tomcat-7/中描述的解决方案适用于我。

mvn插件tomcat-maven-plugin可以很好地与tomcat 5.5配合使用,但是当你尝试部署到tomcat 7实例时它会产生403错误。原来tomcat 7改变了部署的URL,所以你需要配置插件来使用这个不同的url。你可以用下面的插件配置做到这一点:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>tomcat-maven-plugin</artifactId> 
    <configuration> 
     <url>http://localhost:8080/manager/html</url> 
    </configuration> 
</plugin> 

神奇的是,现在使用/经理/ HTML,而不仅仅是/经理的默认网址的URL设置。最初源出于此信息:http://www.jroller.com/Fabszn/entry/tomcat_7_et_le_plugin

+0

此外,还需要对具有“/ manager/html”路径权限的用户执行部署。我已经为该用户添加了一个角色“manager-gui”。 – 2013-02-04 20:29:18

+0

更新:我下载了Tomcat7_U40,并且部署工作不像前面评论中描述的那样工作,而在Tomcat7_U30上工作良好。然后,我将url更改为“http:// localhost:8080/manager/text”,并将角色设置为“manager-gui”和“manager-script”进行部署。它以这种方式工作! – 2013-05-30 14:05:11

19

在这个问题上我居然遇到了这个问题,最近设置我的Ubuntu的箱子和我的解决方案跟进,而不是/ HTML实际上是在/文本指向:代码:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>tomcat-maven-plugin</artifactId> 
    <version>1.1</version> 
    <configuration> 
     <url>http://localhost:8080/manager/text</url> 
     <username>admin</username> 
     <password>admin</password> 
    </configuration> 
    </plugin> 
+3

与我一样,感谢Mutmatt,使用/文本路径工作。为了这个工作,我不得不将管理员脚本角色添加到我的管理员用户。 – derFunk 2012-12-13 17:57:21

+2

这应该是被接受的答案。 – BoD 2013-03-24 15:20:40

+1

为我工作!上升的票:https://issues.apache.org/jira/browse/MTOMCAT-225 – 2013-06-09 21:25:28

0

得到了与以下设置这方面的工作:

MAVEN_HOME/conf目录/ settings.xml中:

<server> 
    <id>myTomcat</id> 
    <username>admin</username> 
    <password>admin</password> 
</server> 

TOMCAT_HOME/conf目录/于MCAT-users.xml中:

<role rolename="manager-gui"/> 
<role rolename="manager-script"/> 
<user username="admin" password="admin" roles="manager-gui,manager-script" /> 

的pom.xml:

<pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.tomcat.maven</groupId> 
      <artifactId>tomcat7-maven-plugin</artifactId> 
      <version>2.1</version> 
      <configuration> 
       <server>myTomcat</server> 
       <url>http://localhost:8080/manager/text</url> 
       <path>/${project.build.finalName}</path> 
      </configuration> 
     </plugin> 
    </plugins> 
    </pluginManagement> 

部署有:

mvn clean install tomcat7:redeploy 
相关问题