1

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
chelder
  • 3,819
  • 6
  • 56
  • 90
  • FYI @chelder Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles. – Lucky Jun 23 '14 at 07:09

1 Answers1

3

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

pvm14
  • 544
  • 3
  • 11
  • Thank you. In my Eclipse-Tomcat version is not so easy to find that option. So I'm going to update my question to add how to open the file: Tomcat v7.0 Server at localhost.server (in your case Tomcat v6.0). – chelder Apr 08 '13 at 11:02
  • Sorry, I was too optimistic, and I thought it would work. It does not deploy correctly because the war is not created in the webapp of Tomcat: Building war: E:\chelder\Documents\eclipse_workspaces\git_IngenieriaWeb_tests\practica\target\practicaIW-0.0.1-SNAPSHOT.war Do you know how to configure maven-war-plugin to build it in the Tomcat folder? :/ – chelder Apr 08 '13 at 16:58
  • You don't need to build anything in Tomcat folder neither to configure the plugin in any way to do that. It uploads the war for you to the proper location if it's pointing to the right url with the right credentials. To set the option I was talking about (either for Tomcat 6 or 7) you just have to double click the server (point 3 on your image) and the window that I pasted will appear. Regards – pvm14 Apr 08 '13 at 19:50
  • Exactly, the url was incomplete. This one is working in my case: http://127.0.0.1:8080/manager/text If you read it and still get the 403 error, I suggest to check it too: http://stackoverflow.com/questions/5410479/tomcat-maven-plugin-403-error Thank you for all your help pvm14! :) – chelder Apr 19 '13 at 08:56