8

I'm trying to get manager/deploy working on my new installation of Tomcat 7.0.34, but I keep getting a 403 when I try to deploy by doing a PUT on http://localhost:8080/manager/deploy. I've yet to get this working in Tomcat 7.

conf/server.xml

<?xml version='1.0' encoding='utf-8'?>
<Server>
...
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
          type="org.apache.catalina.UserDatabase"
          description="User database that can be updated and saved"
          factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service>
  ...
    <Engine>
    ...
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
           resourceName="UserDatabase"/>
    </Engine>
  </Service>
</Server>

conf/tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
    <user username="tomcat" password="redacted" roles="manager-script"/>
</tomcat-users>

I've also tried (with the same result)

conf/tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
    <role rolename="manager-script"/>
    <user username="tomcat" password="redacted" roles="manager-script"/>
</tomcat-users>

And yes, I've double, triple, quadruple checked that I'm using the correct username and password, as defined in the tomcat-users.xml. I thought this was all I needed. Any ideas?

Cody S
  • 4,744
  • 8
  • 33
  • 64

2 Answers2

9

So, I finally figured it out!

First, all of the settings above are correct (either version of tomcat-users above is correct, but I think the first one is more correct.

It may not have been clear, originally, but I was migrating from Tomcat 6. What I was missing was the URL that I was PUTting to. It should have been: http://localhost:8080/manager/**text**/deploy

Now everything works great. I hope this helps somebody in the future :)

Cody S
  • 4,744
  • 8
  • 33
  • 64
  • Indeed, the url has changed between Tomcat 6 and Tomcat 7. I've found another small difference in Tomcat 7, which could be relevant to some readers: the Catalina Manager mbean name has changed ("Catalina:type=Manager, context=${app.path}, host=...", Tomcat 6 used path instead of context). – proko Jan 09 '13 at 11:13
  • Cool! I don't use mbeans personally, but I figure we could get some nice information here that might save somebody some pain in the future. There is a shocking lack of examples for the manager-script role in Tomcat 7. Then again, if I had read the documentation carefully, I wouldn't have had a problem in the first place ;) – Cody S Jan 09 '13 at 17:36
0

1st one is the best solution. I faced this problem and solved by adding following lines in tomcat-users.xml file.

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
    <user username="tomcat" password="redacted" roles="manager-script"/>
</tomcat-users>
Faiz Ahmed
  • 396
  • 6
  • 13