tomcat-maven-plugin: Server returned HTTP response

2019-01-27 05:43发布

I'm trying to automatically deploy a Maven webapp from Eclipse Java EE to my local Tomcat server. I'm using Windows XP. This is the error:

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project practicaIW: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://127.0.0.1:8080/manager/deploy?path=%2Fpractica-3&war= -> [Help 1]

I think I know the reason of this error:

  • If I run the Tomcat server inside eclipse, 127.0.0.1:8080 is my workspace/target. There is any manager folder and rest of classes on it, so it does not work. Possible botched solution: copy this folder and files inside my project.
  • If I run the Tomcat server outside eclipse, 127.0.0.1:8080 is tomcat_location/webapps. It does not work because Eclipse creates the war file in my workspace so Tomcat cannot find it. Possible solution: configure the maven-war-plugin to create the war file into 127.0.0.1:8080. How could I do it? Is it the best way to procceed?

pom.xml extract:

 <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
        <url>http://127.0.0.1:8080/manager</url>
        <username>admin</username>
        <password>password</password>
        <server>TomcatServer</server>
        <path>/practica-3</path>
    </configuration>
 </plugin>

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
       <warSourceDirectory>WebContent</warSourceDirectory>
       <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>

tomcat-users.xml extract:

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

UPDATE: pvm14 answered the question. But previously you have to open the file: Tomcat v7.0 Server at localhost.server. Here is how:

  1. Properties
  2. Clicking on Switch location, the file that the arrow 3 indicate will appear.
  3. Open the file enter image description here

1条回答
爷的心禁止访问
2楼-- · 2019-01-27 06:07

The Tomcat server you start from inside Eclipse isn't going to have a 'Tomcat Manager' console available (localhost:8080/manager) unless you configure it with this option:

enter image description here

This means that the Tomcat you start from Eclipse is exactly the one you provided when defining the Tomcat server in the IDE. Otherwise Eclipse runs a pruned version, without manager available, in a directory located inside the workspace:

{workspace_dir}\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

If you don't have a tomcat manager available in the instance you're running tomcat-maven-plugin won't be able to deploy anything

Best regards

查看更多
登录 后发表回答