maven-tomcat插件部署在远程服务器上 [英] maven-tomcat plugin deploy on Remote server

查看:86
本文介绍了maven-tomcat插件部署在远程服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的应用程序与maven部署在远程服务器上,以便拥有一个持续集成的系统:).

I want to deploy my application with maven on a remote server in order to have a continuous integration system :).

我检查了很多关于stackoverflow的问题,但是无法使其正常工作.首先,我将向您展示我的错误,然后是我进行的配置. 这是关于上传的消息,似乎是正确的: Uploaded: http://SERVEUR_IP/manager/text/deploy?path=%2FGiveMeAShow (49631 KB at 51.5 KB/sec)

I've checked many issues on stackoverflow but couldn't make it work. First I'll show you my error, then the configuration I've made. Here si the message about the upload, it seems to be correct : Uploaded: http://SERVEUR_IP/manager/text/deploy?path=%2FGiveMeAShow (49631 KB at 51.5 KB/sec)

错误:

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project GiveMeAShow: Tomcat return http status error: 401, Reason Phrase: Unauthorized:
[ERROR] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[ERROR] <html>
[ERROR] <head>
[ERROR] <title>401 Unauthorized</title>
[ERROR] <style type="text/css">
[ERROR] <!--
[ERROR] BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
[ERROR] H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
[ERROR] PRE, TT {border: 1px dotted #525D76}
[ERROR] A {color : black;}A.name {color : black;}
[ERROR] -->
[ERROR] </style>
[ERROR] </head>
[ERROR] <body>
[ERROR] <h1>401 Unauthorized</h1>
[ERROR] <p>
[ERROR] You are not authorized to view this page. If you have not changed
[ERROR] any configuration files, please examine the file
[ERROR] <tt>conf/tomcat-users.xml</tt> in your installation. That
[ERROR] file must contain the credentials to let you use this webapp.
[ERROR] </p>
[ERROR] <p>
[ERROR] For example, to add the <tt>manager-gui</tt> role to a user named
[ERROR] <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
[ERROR] config file listed above.
[ERROR] </p>
[ERROR] <pre>
[ERROR] &lt;role rolename="manager-gui"/&gt;
[ERROR] &lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
[ERROR] </pre>
[ERROR] <p>
[ERROR] Note that for Tomcat 7 onwards, the roles required to use the manager
[ERROR] application were changed from the single <tt>manager</tt> role to the
[ERROR] following four roles. You will need to assign the role(s) required for
[ERROR] the functionality you wish to access.
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-script</tt> - allows access to the text interface and the
[ERROR] status pages</li>
[ERROR] <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-status</tt> - allows access to the status pages only</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] The HTML interface is protected against CSRF but the text and JMX interfaces
[ERROR] are not. To maintain the CSRF protection:
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li>Users with the <tt>manager-gui</tt> role should not be granted either
[ERROR] the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
[ERROR] <li>If the text or jmx interfaces are accessed through a browser (e.g. for
[ERROR] testing since these interfaces are intended for tools not humans) then
[ERROR] the browser must be closed afterwards to terminate the session.</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] For more information - please see the
[ERROR] <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
[ERROR] </p>
[ERROR] </body>
[ERROR]
[ERROR] </html>
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

看起来很清楚,这是授权问题.让我们看一下我的远程tomcat7 tomcat-users.xml文件:

It seems pretty clear, it's an authorization problem. Let's have a look at my remote tomcat7 tomcat-users.xml file :

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
        <role rolename="manager-gui"/>
        <role rolename="admin-gui"/>
        <role rolename="manager-script"/>
        <role rolename="admin-script"/>
        <user username="admin" password="password" roles="manager-gui,manager-script,admin-gui,admin-script" />
</tomcat-users>

我知道我不应该授予所有角色,但是嘿,它不起作用,所以我正在尝试:).

I know I should not grant all the roles, but hey it doesn't work so I'm trying :).

我能够在浏览器中使用"admin"和"password"通过HTTP登录应用程序管理器/管理页面.我认为这很好.

I am able to log into app manager/admin page via HTTP in my browser with "admin" and "password". I think this is fine.

这是我在maven-tomcat-plugin中的配置:

Here is my configuration in maven-tomcat-plugin :

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <usernamee>admin</usernamee>
        <password>password</password>
        <url>http:SERVEUR_IP/manager/text</url>
        <server>TomcatServer</server>
        <path>/GiveMeAShow</path>
    </configuration>
</plugin>

当我开始尝试时,我无法上传war文件.加上这个允许我这样做.但是似乎授权问题稍后出现.

When I started to try I was not able to upload the war file. Adding this has permitted me to do so. But it seems the authorization problem comes later.

我还在我的远程服务器的~/.m2/settings.xml中放置了settings.xml文件:

I've also put a settings.xml file in my remote server in ~/.m2/settings.xml :

<?xml version='1.0' encoding='utf-8'?>
<servers>
        <server>
                <id>TomcatServer</id>
                <username>admin</username>
                <password>password</password>
        </server>
</servers>

~/.m2文件夹仅包含一个子文件夹以及我创建的该文件.

The ~/.m2 folder only contains one subfolder and this file I created.

请注意,我正在使用root用户执行所有这些操作.

Note that I'm doing all this stuff using root user.

我不知道现在要尝试什么,谢谢您的帮助!

I don't know what to try now, thank's for your help !

编辑

我确实喜欢@fatteddy说: -创建了仅部署用户.仅扮演经理脚本"角色 -更正了pom.xml中的错误,将<usernamee>更改为</username>

I did like @fatteddy said : - Created a deployment-only user. With only the role "manager-script" - Corrected my error in pom.xml, changing <usernamee> to </username>

我认为创建仅部署用户的大部分工作是在我同时在TRAVIS-CI上进行测试时完成的,而<username>标签中的env变量却写得没有错误.

I think creting a deployment-only user did the most of the job as I was testing on TRAVIS-CI at the same time with env variables in <username> tags written without errors.

推荐答案

实际上这是一个身份验证问题. 尝试(显然出于安全原因)定义一个单独的部署用户,并为其分配manager-script(仅此)角色.不要忘记重启tomcat.

actually this is an authentication issue. Try to define (for security reasons obviously) a separate deployment-user with the the manager-script (this an only this) role assigned. Don't forget to restart tomcat.

如果这不能帮助更改tomcat管理器URL的路径段(manager/managermanager/textmanager/text/->的组合),据我所知,存在/或存在问题带有斜杠,这些斜杠已在更高版本的tomcat版本中修复)

If this does not help change the path segment of the tomcat manager URL (combinations of manager/, manager, manager/text, manager/text/ -> as far as i can remember there are/or have been issues with trailing slashes which have been fixed in later tomcat versions)

这篇关于maven-tomcat插件部署在远程服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆