2012-01-22 12 views
5

2つのモジュールでダミーのmavenプロジェクトを作成しています。一般的なpom.xmlファイルが含まれています。私はrootのpom.xmlファイルからビルドしてすべてのテストを実行することができますが、Tomcatにファイルをデプロイする場合は、それが落ちます。私が持っているプラ​​グインは次のとおりです。tomcat-maven-pluginが間違ったURLにデプロイしようとしているのはなぜですか?

<build> 
    <finalName>dummy</finalName> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>tomcat-maven-plugin</artifactId> 
      <configuration> 
       <url>http://127.0.0.1:8090/manager/text</url> 
       <server>TomcatServer</server> 
       <path>/dummy</path> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

のsettings.xml

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

しかし、私はそれがデフォルトの設定値を使用してビルドを実行し、私は次のエラーメッセージを取得する場合:

をTomcatマネージャを呼び出すことができません:http://localhost:8080/manager/deploy?path=%2Fwebapp&war= - > [ヘルプ1]

(このプロジェクト概要は機械翻訳されたものです)プロジェクト概要の原文を表示する|翻訳してみるプロジェクト概要の原文10

誰でも私の設定を使用するプラグインを得る方法を知っていますか?

より出力:

[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ webapp --- 
[INFO] Packaging webapp 
[INFO] Assembling webapp [webapp] in [C:\Websites\www.dummy.app\webapp\target\webapp] 
[INFO] Processing war project 
[INFO] Copying webapp resources [C:\Websites\www.dummy.app\webapp\src\main\webapp] 
[INFO] Webapp assembled in [15 msecs] 
[INFO] Building war: C:\Websites\www.dummy.app\webapp\target\webapp.war 
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored 
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true') 
[INFO] 
[INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) @ webapp <<< 
[INFO] 
[INFO] --- tomcat-maven-plugin:1.1:deploy (default-cli) @ webapp --- 
[INFO] Deploying war to http://localhost:8080/webapp 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Summary: 
[INFO] 
[INFO] my-app ............................................ SUCCESS [4.747s] 
[INFO] webapp ............................................ FAILURE [3.313s] 
[INFO] dummy ............................................. SKIPPED 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 9.376s 
[INFO] Finished at: Mon Jan 23 22:46:11 GMT 2012 
[INFO] Final Memory: 18M/245M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project webapp: Cannot invoke Tomcat manager: http://localhost:8080/manager/deploy?path=%2Fwebapp&war= -> [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 
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command 
[ERROR] mvn <goals> -rf :webapp 

おかげ

+1

で利用できるようになりますあなたのマネージャーのURLは奇妙に見える - なぜですそこに '/ text'という名前がありますか?また、Tomcatがポート8080上で動作するように正しく設定されていることと、マネージャーアプリがインストールされていることを確認しましたか? – Perception

+1

Tomcat7に展開する場合、URLは/ htmlまたは/ textで終わる必要があります。私はそれが/テキストでなければならないと思うが、私はこれまでテストしていない。 http://127.0.0.1:8090/manager/htmlがTomcat Managerに解決するので、Tomcatは正しいポートで動作しています – BIGDeutsch

+1

関連するコンソールログをデバッグモード( 'mvn -X')で実行してもらえますか? – Raghuram

答えて

3
<properties> 
    <maven.tomcat.url>http://localhost:8080/manager/text</maven.tomcat.url> 
</properties> 

を参照してください。

1

私も同じ問題を抱えていました。私はどのように解決しましたか。これは遅い回答ですが、今日でもこの答えが成立すると思います。

私はtomcat7.Theのtomcat-mavenの-プラグインを使用しています:TomcatのデプロイメントURL http://localhost:8080/manager/htmlに1.1のデフォルトを、しかし7TomcatのためのURLがhttp://localhost:8080/manager/textに変更されました。

ステップ1:warファイルを展開するためのtomcat用のURL &を探します。

私は手動で

apache-tomcat-7.0.41\webapps\manager\WEB-INF\web.xml 

に行くことによって展開するためのURLがあることがわかった:Mavenのはhttp://localhost:8080/manager/text を使用する必要がありますので、このURLの役割は、「マネージャー・スクリプトで、/テキスト

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>Text Manager interface (for scripts)</web-resource-name> 
     <url-pattern>/text/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
     <role-name>manager-script</role-name> 
    </auth-constraint> 
    </security-constraint> 

ステップ2:設定ロールのためのTomcat資格情報

これで、私たちは、戦争とロールを展開するURLを見つけました。あなたが構成されたTomcatユーザーでない場合。下は、apache-tomcat-7.0.41 \ conf \ tomcat-users.xml。

<tomcat-users> 

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

</tomcat-users> 

手順3:展開のためのTomcatのURLを使用するのpom.xmlでのtomcat-mavenの-プラグインを設定します。

これらを使用するようにtomcat-maven-pluginを設定する必要があります.Belowはpom.xmlのプラグイン設定です。これはtomcat-maven-pluginのデフォルトのtomcat deploy urlを上書きします。

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

ステップ4:TomcatのURLの資格情報のためのMavenののsettings.xmlを設定します。

tomcatにwarファイルを展開するためのmavenプラグインでは、tomcatサーバー用にユーザ名&パスワード が必要です。 配置されているのmavenののsettings.xmlをご覧ください(私は、Apache-のmaven-3.2.3 \ confにあった)と

<servers> 
    <server> 
     <id>mytomcatserver</id> 
     <username>admin</username> 
     <password>admin</password> 
    </server> 
</servers> 

ステップ5に以下の設定を適用します:真実の瞬間

tomcatを起動します。

MVNパッケージ(warファイルが作成された)

MVNのtomcat:デプロイ(戦争の展開のためのTomcatのコンソールを見る)

あなたのWebアプリケーションは、http://localhost:8080/{context}

関連する問題