10

I have a tomcat7. Access to manager app (http://localhost:7777/manager/html) works fine with the credentials defined in tomcat-users.xml.

Now I want to deploy an application with maven3. I configured the tomcat maven plugin:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0-beta-1</version>
    <configuration>
        <url>http://localhost:7777/manager</url>
        <server>localhost7777</server>
    </configuration>
</plugin>
<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat6-maven-plugin</artifactId>
    <version>2.0-beta-1</version>
    <configuration>
        <url>http://localhost:7777/manager</url>
        <server>localhost7777</server>
    </configuration>
</plugin>

In mavens setting.xml I added the entry for the server:

<servers>
    <server>
        <id>localhost7777</id>
        <username>manager</username>
        <password>secret</password>
    </server>
</servers>

Now application will be build successful. But the goal tomcat7:deploy leads to a access denied error message from the tomcat:

...
[INFO] Deploying war to http://localhost:7777/workload-monitor  
Uploading: http://localhost:7777/manager/deploy?path=%2Fworkload-monitor&update=true
Uploaded: http://localhost:7777/manager/deploy?path=%2Fworkload-monitor&update=true (2329 KB at 55435.1 KB/sec)

[INFO] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[INFO] <html>
[INFO]  <head>
[INFO]   <title>403 Access Denied</title>
[INFO]   <style type="text/css">
[INFO]     <!--
...

Could somebody give me a hint?

3
  • Which one is the correct one? tomcat6- or tomcat7- ?
    – khmarbaise
    Mar 30, 2012 at 10:43
  • Both have to be defined in the pom.xml because some goals are only available in the tomcat6 mojo (see tomcat.apache.org/maven-plugin-2/index.html).
    – magomi
    Mar 30, 2012 at 10:50
  • 1
    First make it run in your case with only tomcat7 but not both. After that you need to think about a profile for the other goals.
    – khmarbaise
    Mar 30, 2012 at 11:13

4 Answers 4

19

To follow up on this question I actually ran into this issue setting up my ubuntu box recently and my solution, instead of /html was actually to point at /text: Code:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <version>1.1</version>
    <configuration>
      <url>http://localhost:8080/manager/text</url>
      <username>admin</username>
      <password>admin</password>
    </configuration>
  </plugin>
2
  • 3
    Same with me, thanks Mutmatt, using the /text path worked. For that to work I had to add the manager-script role to my admin user.
    – derFunk
    Dec 13, 2012 at 17:57
  • Thank you, saved my sanity late on a friday afternoon!
    – PiersyP
    May 16, 2014 at 16:19
3

Solution described in http://mycodenotes.wordpress.com/2011/01/25/mvn-tomcatdeploy-to-tomcat-7/ worked for me.

The mvn plug-in tomcat-maven-plugin works fine with tomcat 5.5, but it gives a 403 error when you try to deploy to a tomcat 7 instance. Turns out tomcat 7 changed the urls for deploying, so you need to configure the plugin to use this different url. You can do this with the following plugin configuration:

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

The magic is in the URL setting that now uses /manager/html, rather than the default url of just /manager. The original source for this information: http://www.jroller.com/Fabszn/entry/tomcat_7_et_le_plugin

2
  • Also, it is required to perform deploy with a user who has permissions for "/manager/html" path. I've added a role "manager-gui" to that user. Feb 4, 2013 at 20:29
  • Update: I downloaded Tomcat7_U40 and deploy was not working as I described in previous comment, while it worked fine on Tomcat7_U30. Then I changed url to "localhost:8080/manager/text" and set a user for deploy with roles "manager-gui" and "manager-script". It works in that way! May 30, 2013 at 14:05
1

While not an answer to the question, the problem seems to be due to the fact that tomcat:deploy tries to deploy the webapp to http://localhost:7777/manager/deploy while it tomcat7, the deploy url is http://localhost:777/manager/html/deploy. There doesn't appear to be a way to specify this as a plugin configuration.

0

Got this working with following settings:

MAVEN_HOME/conf/settings.xml:

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

TOMCAT_HOME/conf/tomcat-users.xml:

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

pom.xml:

  <pluginManagement>
     <plugins>
        <plugin>
           <groupId>org.apache.tomcat.maven</groupId>
           <artifactId>tomcat7-maven-plugin</artifactId>
           <version>2.1</version>
           <configuration>
              <server>myTomcat</server>
              <url>http://localhost:8080/manager/text</url>
              <path>/${project.build.finalName}</path>
           </configuration>
        </plugin>
     </plugins>
  </pluginManagement>

Deploy with:

mvn clean install tomcat7:redeploy
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.