tomcat-maven-plugin 403 error
Asked Answered
G

21

33

When I use mvn tomcat:deploy of tomcat-maven-plugin there is a 403 error:

Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.0:deploy (default-cli) on project my-webapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/text/deploy?path=%2Fdms&war=

I think it because of null war parameter. But why is it null???

In pom.xml there is:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>

  <configuration>
    <warFile>target\my-webapp.war</warFile>
    <server>myserver</server>
    <url>http://localhost:8080/manager/text</url>
    <path>/dms</path>
  </configuration>
</plugin>
Grube answered 23/3, 2011 at 19:21 Comment(0)
M
14

The /manager application is by default secured by username/password. If you enter http://localhost:8080/manager you will be asked to provide security credentials as well. First create/enable user in Tomcat: after canceling or few unsuccessful attempts Tomcat will provide help on error screen. Then use these credentials in tomcat-maven-plugin as explained here:

Add a plugin configuration block to your pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
            <server>myserver</server>
    </configuration>
</plugin>

Add a corresponding server block to your settings.xml:

<server>
    <id>myserver</id>
    <username>myusername</username>
    <password>mypassword</password>
</server>
Microcyte answered 23/3, 2011 at 19:31 Comment(0)
P
45

you should use /text:

http://localhost:8080/manager/text

and also add to user role manager-script

Program answered 10/6, 2012 at 22:5 Comment(3)
muchas gracias my friend... you ended a huge journey for meMarjana
This. This is the working solution. Worked for tomcat 7.0.53.Strangles
worked for me while just using server:8080 - no needed to use /manager at allSarong
M
27

You you're using tomcat 7, you should leave your plugin configuration in pom.xml like this:

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

I have tried with the version configuration, like above example, but it didn't work for me. In settings.xml shoud have the configuration of the server, matching with the value in the pom.xml

<settings>
    <servers>
        <server>
            <id>tomcat</id>
            <username>admin</username>
            <password>admin</password>
        </server>
    </servers>
</settings>

So, mvn tomcat:deploy or mvn tomcat:redeploy (if you have deployed the app already), or mvn tomcat:run (with tomcat down) should work.

Mellissamellitz answered 29/8, 2011 at 3:42 Comment(2)
The trailing "/html" was key- I needed that to get it working on Tomcat 7 as well.Nikianikita
For some, tomcat 7 seems to require a URL like: <localhost:8080/manager/text>. See this answer to a related question.Boddie
M
14

The /manager application is by default secured by username/password. If you enter http://localhost:8080/manager you will be asked to provide security credentials as well. First create/enable user in Tomcat: after canceling or few unsuccessful attempts Tomcat will provide help on error screen. Then use these credentials in tomcat-maven-plugin as explained here:

Add a plugin configuration block to your pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
            <server>myserver</server>
    </configuration>
</plugin>

Add a corresponding server block to your settings.xml:

<server>
    <id>myserver</id>
    <username>myusername</username>
    <password>mypassword</password>
</server>
Microcyte answered 23/3, 2011 at 19:31 Comment(0)
D
8

you just have to change the url by adding the "/html" so it will be like this http://localhost:8080/manager/html and bingo it works Hope that help

Dakotadal answered 25/1, 2012 at 9:59 Comment(1)
thanks @amira. This emphasizing from your make my problem solved! thanksCar
R
8

For Tomcat7, in tomcat-users.xml you need rolename manager-script also:

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

and in project's POM.xml

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>tomcat-maven-plugin</artifactId>
   <configuration>
        <url>http://localhost:8080/manager/text</url>
        <server>myserver</server>
        <path>/sw</path>
   </configuration>
</plugin>

and maven's settings.xml:

<servers>
 <server>
  <id>myserver</id>
  <username>tomcat</username>
  <password>s3cret</password>
 </server>
</servers>
Rumery answered 8/4, 2013 at 10:44 Comment(1)
Although the code is appreciated, it should always have an accompanying explanation. This doesn't have to be long but it is expected.Moonrise
R
7

There are a few steps one must be sure that are accomplished. this can be a true black hole.

If your are using tomcat-maven-plugin from org.codehaus.mojo, you must use this configuration:

<configuration>
    <url>http://localhost:8080/manager/text</url>
    <warFile>your_war_filename.war</warFile>
    <server>server_name_on_settingsxml</server>
</configuration>

Please ensure that you have 'server_name_on_settingsxml' server credentials defined on maven settings.xml. Use mvn tomcat:deploy (you must use this 'tomcat' prefix), this is the only way that when deploying the above configurations are read.

However if you are using tomcat7-maven-plugin from org.apache.tomcat.maven, you must use mvn tomcat7:deploy. The 'tomcat7' prefix will read configuration from plugin:

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>

I was using tomcat:deploy, and i had on the pom.xml the tomcat7-maven-plugin defined. So, the maven deploy was never reading my configurations tag...

If you ensure you have usernames and passwords correctly define and you use the correct plugin when deploying, it will work.

Rabassa answered 14/7, 2012 at 0:44 Comment(0)
R
6

You can have a 403 error if you try to use the codehouse tomcat plugin version 1.1 to deploy on a Tomcat 7 server. Version 1.1 doesn't support Tomcat 7 yet.

If you are using Tomcat 7 you should use Cargo.

Rafflesia answered 29/4, 2011 at 16:9 Comment(0)
C
5

If you are using Tomcat 7:

  1. Change your configuration in pom.xml to use the Tomcat 7 version of the plugin

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <url>http://127.0.0.1:8080/manager/html</url>
            <server>TomcatServer</server>
            <path>/your_context</path>
            <username>some_user_name</username>
            <password>some_password</password>
        </configuration>
    </plugin>
    

Notice the and values - they are DIFFERENT from the ones for Tomcat 6.

  1. Don't forget to change the "tomcat:deploy" to "tomcat7:deploy" in your scripts, or External Tools Configurations launchers in Eclipse.
  2. Add a server configuration to your settings.xml, usually located under .m2 folder
<server>
    <id>TomcatServer</id>
    <username>some_user_name</username>
    <password>some_password</password>
</server>
  1. If you need additional options, like deploying a WAR file located in a non-standard folder, visit: Tomcat 7 Maven Plugin
Carbineer answered 28/5, 2013 at 5:10 Comment(0)
V
4

I discovered that I had to use the following string instead of "html":

http://localhost:8080/manager/text
Vicinal answered 29/1, 2013 at 19:20 Comment(0)
E
3

This is also possible:

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
        <server>myserver</server>
        <username>admin</username>
        <password>admin</password>
    </configuration>
</plugin>
Epicureanism answered 1/7, 2011 at 20:3 Comment(1)
The problem here is that you'll deploy the .pom file along with your credentials. settings.xml will not be deployed.Lovmilla
P
3

If you use Tomcat 7 you need to refer to the url http://localhost:8080/manager/html in the tomcat plugin.

http://mojo.codehaus.org/tomcat-maven-plugin/examples/deployment-tomcat7.html

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>
  <version>1.2-SNAPSHOT</version>
  <configuration>
    <url>http://localhost:8080/manager/html</url>
  </configuration>
</plugin>
Phalangeal answered 22/8, 2011 at 16:51 Comment(0)
U
3

If you are using version 7, there's a catch: the access to the /manager/text resource is not enabled by default.

You must create a user with the role mananger-script, as it says in the documentation

It would be quite unsafe to ship Tomcat with default settings that allowed anyone
on the Internet to execute the Manager application on your server.
Therefore, the Manager application is shipped with the requirement that anyone
who attempts to use it must authenticate themselves, using a username and
password that have the role manager-script associated with them.
Further, there is no username in the default users file
($CATALINA_BASE/conf/tomcat-users.xml) that is assigned this role.
Therefore, access to the Manager application is completely disabled by default.

To enable access to the Manager web application, you must either create a new
username/password combination and associate the role name manager-script with it,
or add the manager-script role to some existing username/password combination.

Hope it helps :)

Ulyanovsk answered 10/9, 2011 at 8:10 Comment(0)
A
2

I used to get the same error, you just have to make sure that tomcat-users.xml file contain the user (admin in my case) with roles as (manager, manager-gui, admin, manager-script).

I have tomcat 7, maven 3 on ubuntu.

Atlantis answered 15/9, 2011 at 3:59 Comment(0)
C
1

You only have to add the manager-script and manager roles to your tomcat user in tomcat-users.xml in config folder. In Tomcat 7 you have to specify different roles for different manager GUI access which in this case goes to text. At the end for text interface you have to use a manager-script role.

Channing answered 16/10, 2011 at 15:37 Comment(0)
C
1

May be you should check your configuration file in ~/.m2/settings.xml this file have to be with the follow struct :

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
</settings>

After that you should to be sure that your server conf is correct for your project, instance of:

  <servers>
     <server>
        <id>mytomcat</id>
        <username>test</username>
        <password>test</password>
     </server>
  </servers>

later run mvn tomcat:deploy. Remember that also you could run tomcat:deploy -X for see the debbug.

Colombes answered 23/5, 2012 at 10:18 Comment(0)
A
1

This solution is for "Apache" Tomcat7 plugin: As it is already mentioned before you need to add "/text" to the end of the url

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
    <port>8080</port>
    <path>/deployPath</path>
    <url>http://localhost:8080/manager/text</url>
    <server>TomcatServer</server>
</configuration>

Configure you "settings.xml" which is located inside .m2 folder

<servers>
    <server>
        <id>TomcatServer</id>
        <username>script-admin</username>
        <password>password</password>
    </server>
</servers>

Since you use Tomcat 7, the MOST important thing is that you should create a different user for "manager-script" role, as it is mentioned in the documentation!

<role rolename="manager-script"/>
<user username="tomcat" password="password" roles="manager-script"/>
Accommodating answered 20/3, 2015 at 9:34 Comment(0)
Z
0

If you are facing a problem regarding user name and password please do not worry, there is a file in tomcat directory named tomcat-user.xml, go there and see the name and password attributes and use when the prompt ask for user name and password.

If still you are unable to open apache home page do one thing, in the tomcat directory there is another file named server.xml go and change port 8080 to this

Zaratite answered 24/4, 2012 at 17:55 Comment(0)
L
0

If you are using Eclipse with the plugin m2eclipse and you still have this error after trying these solutions, it could be because this plugin has not the manager included. You should download Tomcat separately and configure Eclipse to use it (check this link: tomcat-maven-plugin: Server returned HTTP response code: 403)

Lianneliao answered 19/4, 2013 at 8:59 Comment(1)
OK. I modified it. Is it better now? :)Lianneliao
A
0

Passing from tomcat6 to tomcat7 recap:

  1. Add roles in tomcat-user.xml
  2. Add /text or /html to your url
  3. Change plugin version

    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <version>2.2</version>
    
  4. Change the option tomcat:deploy with tomcat7:deploy

Arm answered 18/11, 2013 at 12:25 Comment(0)
A
0

I have spent over three days on Server returned HTTP response code: 400 while trying to deploy web application onto Tomcat Server 8.0 bundled with Netbeans. When I used mvn tomcat7:deploy over command line, everything worked perfect, but no success through Netbeans IDE. I have set tomcat maven plugin in POM.xml

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <configuration>
        <url>http://localhost:8080/manager/text</url>
        <server>tomcat</server>
    </configuration>
</plugin>

plus server record in .m2/conf/settings.xml for Maven,

<settings>
    <servers>
        <server>
            <id>tomcat</id>
            <username>admin</username>
            <password>admin</password>
        </server>
    </servers>
</settings>

even appropriate tomcat user in tomcat-users.xml

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

but still without success. The root cause was Proxy server used in our company and Netbeans settings. In Netbeans, go to Tools -> Options and on General tab, use Manual Proxy Settings instead of System Proxy Settings (even if System Proxy Settings works). It helped me and now I am able to deploy web app on Tomcat 8 from Netbeans directly. You can also set No Proxy when you are using only localhost server. Root cause for my trouble was bad proxy set in default web browser, which is the source for option System Proxy Settings.

Archeozoic answered 21/10, 2014 at 11:18 Comment(0)
S
0

I also get the 403 error, but only when I connect via Apache 2. When I use port 8080 and deploy to tomcat directly it works. So: try to add port 8080 to the URL

I am still trying to figure out why it does not work via Apache. I am using ProxyPass / ajp://localhost:8009/ and

<Location "/manager" >
     Order allow,deny
     Allow from 62.245.147.202
     Satisfy Any
   </Location>
Stutter answered 23/10, 2015 at 11:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.