2011-09-20 101 views
3

我想部署一個戰爭,從maven的遠程Tomcat服務器,但我得到了NetBeans以下錯誤:不能調用Tomcat管理:服務器返回的HTTP響應代碼:401

Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) 
on project noca: Cannot invoke Tomcat manager: 
Server returned HTTP response code: 401 for URL: 
http://12.34.56.78/manager/html/deploy?path=%2Fnoca&war= -> [Help 1] 

我覺得奇怪war沒有價值,我不知道爲什麼。

當我瀏覽這個網址,我得到Tomcat的經理如下:

FAIL - Invalid context path null was specified 

這裏是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>net.test</groupId> 
    <artifactId>noca</artifactId> 
    <version>1.0.0</version> 
    <packaging>war</packaging> 

    <properties> 
     <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>javax</groupId> 
      <artifactId>javaee-web-api</artifactId> 
      <version>6.0</version> 
      <scope>provided</scope> 
     </dependency> 

     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.2</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <compilerArguments> 
         <endorseddirs>${endorsed.dir}</endorseddirs> 
        </compilerArguments> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.1.1</version> 
       <configuration> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.1</version> 
       <executions> 
        <execution> 
         <phase>validate</phase> 
         <goals> 
          <goal>copy</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${endorsed.dir}</outputDirectory> 
          <silent>true</silent> 
          <artifactItems> 
           <artifactItem> 
            <groupId>javax</groupId> 
            <artifactId>javaee-endorsed-api</artifactId> 
            <version>6.0</version> 
            <type>jar</type> 
           </artifactItem> 
          </artifactItems> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>tomcat-maven-plugin</artifactId> 
       <configuration> 
        <server>Plasma01</server> 
        <url>http://12.34.56.78/manager/html</url> 
       </configuration> 
      </plugin> 

     </plugins> 
    </build> 

</project> 

服務器在我的Maven setting.xml正確定義。

我在做什麼錯?

P.S.:我看過這個相似的question,但它沒有回答我遇到的問題。

SOLUTION

爲了記錄在案,我修改了pom.xml如下以下阿列克謝的建議,它的工作原理:

<!-- plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>tomcat-maven-plugin</artifactId> 
     <configuration> 
      <server>Plasma01</server> 
      <url>http://12.34.56.78/manager/html</url> 
     </configuration> 
    </plugin --> 

    <plugin> 
     <groupId>org.codehaus.cargo</groupId> 
     <artifactId>cargo-maven2-plugin</artifactId> 
     <configuration> 
      <container> 
       <containerId>tomcat6x</containerId> 
       <type>remote</type> 
      </container> 
     <configuration> 
     <type>runtime</type> 
     <properties> 
      <cargo.tomcat.manager.url> 
       http://12.34.56.78/manager 
      </cargo.tomcat.manager.url> 
      <cargo.remote.username>xxxx</cargo.remote.username> 
      <cargo.remote.password>yyyy</cargo.remote.password> 
     </properties> 
     </configuration> 
      <deployer> 
       <type>remote</type> 
       <deployables> 
        <deployable> 
         <groupId>net.test</groupId> 
         <artifactId>noca</artifactId> 
         <type>war</type> 
        </deployable> 
       </deployables> 
      </deployer> 
     </configuration> 
    </plugin> 

回答

3

嘗試用戶cargo控制Tomcat和部署,很容易和合作。

+3

我在博客上創建了一篇文章,解釋如何使用貨物:http://tshikatshikaaa.blogspot.com/2012/07/how-to-deploy-war-to-tomcat-7-during.html – JVerstry

+0

@ JVerstry現在我使用這樣的簡單bash腳本:http://pastebin.com/mRDYBSS2它對jenkins更有用,幫助我逃離重新部署地獄。我希望你也會喜歡它:) –

相關問題