web-dev-qa-db-ja.com

目標org.codehaus.mojo:Tomcat-maven-plugin:1.1:deploy(default-cli)の実行に失敗しました

mvn Tomcat:deployを実行しようとしていますが、エラーに遭遇しました

 [ERROR] Failed to execute goal org.codehaus.mojo:Tomcat-maven-plugin:1.1:deploy (default-cli) on project appanalytix: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1]
org.Apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:Tomcat-maven-plugin:1.1:deploy (default-cli) on project appanalytix: Cannot invoke
Tomcat manager
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:217)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:84)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:59)
    at org.Apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.Java:183)
    at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:161)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:320)
    at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:156)
    at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:537)
    at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:196)
    at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:141)
    at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:57)
    at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
    at Java.lang.reflect.Method.invoke(Method.Java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:352)
Caused by: org.Apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
    at org.codehaus.mojo.Tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.Java:149)
    at org.codehaus.mojo.Tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.Java:70)
    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:101)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:209)
    ... 19 more
Caused by: Java.net.ConnectException: Connection refused: connect
    at Java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at Java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.Java:69)
    at Java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.Java:339)
    at Java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.Java:200)
    at Java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.Java:182)
    at Java.net.PlainSocketImpl.connect(PlainSocketImpl.Java:157)
    at Java.net.SocksSocketImpl.connect(SocksSocketImpl.Java:391)
    at Java.net.Socket.connect(Socket.Java:579)
    at Java.net.Socket.connect(Socket.Java:528)
    at Sun.net.NetworkClient.doConnect(NetworkClient.Java:180)
    at Sun.net.www.http.HttpClient.openServer(HttpClient.Java:378)
    at Sun.net.www.http.HttpClient.openServer(HttpClient.Java:473)
    at Sun.net.www.http.HttpClient.<init>(HttpClient.Java:203)
    at Sun.net.www.http.HttpClient.New(HttpClient.Java:290)
    at Sun.net.www.http.HttpClient.New(HttpClient.Java:306)
    at Sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.Java:995)
    at Sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.Java:931)
    at Sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.Java:849)
    at org.codehaus.mojo.Tomcat.TomcatManager.invoke(TomcatManager.Java:597)
    at org.codehaus.mojo.Tomcat.TomcatManager.deployImpl(TomcatManager.Java:662)
    at org.codehaus.mojo.Tomcat.TomcatManager.deploy(TomcatManager.Java:295)
    at org.codehaus.mojo.Tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.Java:85)
    at org.codehaus.mojo.Tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.Java:85)
    at org.codehaus.mojo.Tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.Java:141)

maven\conf\settings.xml

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

Tomcat-7.0.39\conf\Tomcat-users

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

pom.xml

  <plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>Tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
    <mode>war</mode>
    <url>http://localhost:8080/manager</url>
    <server>TomcatServer</server>
    <path>/appanalytix</path>
  </configuration>
</plugin>

/ textおよび/ htmlfrom しかし、それはうまくいきません、これを解決するのを手伝ってください

14
user2243194

最初に、 Tomcat-maven-plugin から Apacheソフトウェア基盤 への移動に注意する必要があります。次に、構成要素をmaven/conf/settings.xmlに配置しないでください。代わりに、ユーザーのsettings.xmlファイルHOME/.m2/settings.xmlを使用する必要があります。

上記とは別に、Tomcatへのアクセスには次のURLを使用する必要があります。

http://localhost:8080/manager/html
3
khmarbaise

次の方法は私のために働きます。

  1. 含むようにpom.xmlを変更してください

    <project>
        ...
        <build>    
            <plugins>    
            ....
                <plugin>
                    <groupId>org.Apache.Tomcat.maven</groupId>
                    <artifactId>Tomcat7-maven-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <url>http://localhost:8080/manager/text</url>
                        <server>my-Tomcat</server>
                        <path>/myapp</path>
                    </configuration>
                </plugin>
            </plugins>
            ...
        </build>
        ...
    </project>
    
  2. Tomcat 7サーバーのTomcat_HOME/conf/Tomcat-users.xmlに次の行があることを確認してください:

    <!-- Role to manage WAR files via HTML /manager. The name should be as is! -->
    <role rolename="manager-gui"/>
    <!-- Role to manage WAR files via script like Maven. The name should be as is! -->
    <role rolename="manager-script"/>
    
    <!-- One user cannot have manager-gui and manager-script roles -->
    <user username="managerGui" password="managerPwd" roles="manager-gui"/>
    <user username="manager" password="managerPwd" roles="manager-script"/>
    
  3. パスワードを含めるようにUSER_HOME/.m2/settings.xmlを構成します。

    <settings>
        ...
        <servers>
            ...
            <server>
                <id>my-Tomcat</id>
                <username>manager</username>
                <password>managerPwd</password>
            </server>
        </servers>
    
    </settings>
    
  4. mvn Tomcat7:redeployを使用して展開

詳細は http://Tomcat.Apache.org/Tomcat-7.0-doc/manager-howto.html をご覧ください

21
sancho21

私の場合、解決策はうまくいきました。私は、Apache Tomcat Serverを起動しないという小さな間違いをしました。

これとは別に、タグ内のmaven/conf/setting.xmlに適切なエントリを行うことをユーザーに通知します。

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

Apache Tomcat 7 Tomcat-users.xmlでは、次の行を

<Tomcat-users>

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

Pom.xml内

 <plugin>
    <groupId>org.Apache.Tomcat.maven</groupId>
    <artifactId>Tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://localhost:8888/manager/text</url>
        <server>TomcatServer</server>
        <path>$ReplaceWithWarFileName$</path>
        <update>true</update>
        <username>admin</username>
        <password>password</password>
    </configuration>
</plugin>
0
user1565600
  1. 私のために働いた解決策は実行オプションにありました:

    1_ Mavenインストール

    2_ Mavenビルド

0
Olivier Bont