I can't access Tomcat 7 manager when Tomcat is running through IntelliJ Idea Ultimate 12
Asked Answered
I

7

5

I am trying to access tomcat manager by using

http://localhost:8080/manager

but I am always denied the entrance after I enter the password. I get the following message :

403 Access Denied

You are not authorized to view this page.

If you have already configured the Manager application to allow access and you have used your browsers back button, used a saved book-mark or similar then you may have triggered the cross-site request forgery (CSRF) protection that has been enabled for the HTML interface of the Manager application. You will need to reset this protection by returning to the main Manager page. Once you return to this page, you will be able to continue using the Manager appliction's HTML interface normally. If you continue to see this access denied message, check that you have the necessary permissions to access this application.

If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.

For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.

Note that for Tomcat 7 onwards, the roles required to use the manager application were changed from the single manager role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access.

manager-gui - allows access to the HTML GUI and the status pages manager-script - allows access to the text interface and the status pages manager-jmx - allows access to the JMX proxy and the status pages manager-status - allows access to the status pages only The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection:

Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles. If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session. For more information - please see the Manager App HOW-TO.

Here is my tomcat-users.xml :

<tomcat-users> 
<role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager-gui"/>
  <user username="tomcat" password="s3cret" roles="admin-gui,standard,manager-gui"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

I am running tomcat 7 through intellij idea 12 ultimate. I am using Mountain Lion operating system. Thank you.

Immaterial answered 31/1, 2013 at 13:42 Comment(7)
Works fine for me with Tomcat 7/IDEA 12. Make sure you've configured deployment of the default applications. Not sure you are allowed to have multiple users with the same name and different passwords/roles. I tested it with just one user: <user username="serge" password="serge" roles="manager-gui"/>.Formaldehyde
I've ticked the option you show and I've added another user but the problem remains.Immaterial
Try a clean Tomcat 7 installation with the only change to tomcat-users.xml.Formaldehyde
Crazy coder : Do you run tomcat on a unix system?Immaterial
No, I tested on Windows, however I don't think it's specific to the OS.Formaldehyde
When I run Tomcat 7 with its own startup.sh script I can see the tomcat homepage but I still cannot access the manager.When Tomcat 7 is deployed using intellij's 'catalins.sh run' command I can't even see this home page.Immaterial
skiabox would you please chose my answer as the Answer to your question?Shantae
S
16

I edited two files : server.xml & tomcat-users.xml

STEP 1 : I added this line to the server.xml, this line must be added under Engine context same as the picture:

<Realm className="org.apache.catalina.realm.MemoryRealm" />

here you can see the picture :

enter image description here

STEP 2 : then I edited tomcat-users.xml and added the lines below :

<!--
  NOTE:  The sample user and role entries below are wrapped in a 
  comment and thus are ignored when reading this file. Do not forget
  to remove <!.. ..> that surrounds them.
-->

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

</tomcat-users>

NOTE : I recommend you to copy and paste my text and replace it by yours

Restart tomcat and you're ready to go !

Shantae answered 1/8, 2014 at 14:49 Comment(2)
Part of your answer was helpful to me, but would you mind explaining what does <Realm className="org.apache.catalina.realm.MemoryRealm" /> do?Jacey
+0 I'm pretty sure that the <Realm className="org.apache.catalina.realm.MemoryRealm" /> part is unnecessary. user33296337's answer is better.Underworld
H
3

You need both privilege access, manager-gui and manager-script, for a role.

Example:

    <!-- you need both roles, manager-gui & manager-script for user-->
    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <user username="tomcat" 
      password="blabla" roles="manager-gui,manager-script "/> 
</tomcat-users>
Hexachlorophene answered 19/2, 2014 at 19:5 Comment(0)
I
1

I've solved it by adding CATALINA_HOME variable and giving it the value /Library/Tomcat at the following field :

Run --> Edit Configurations --> Tomcat Server --> Tomcat 7.0 --> 'Startup/Connection' Tab -->Environment Variables

Immaterial answered 31/1, 2013 at 15:6 Comment(3)
This configuration is not needed, normally it's defined when adding a server in IDEA and is passed automatically on start.Formaldehyde
I can confirm the same output on Mac, but /manager app still works just fine without this change.Formaldehyde
The only difference that I can see is that I have created a link with the name /Library/TomcatImmaterial
S
0

I had this same problem. I solved it by changing the owner of the configuration files to tomcat, they were owned by root for some reason.

cd /etc/tomcat
chown tomcat:group *
#restart tomcat service
Supereminent answered 21/6, 2016 at 16:49 Comment(0)
T
0

I faced same problem with my tomcat. I realized that some folders like lib, conf under tomcat didn't have executable(x) permissions. When I gave executable permissions to the folders, problem was solved for me.

Transitory answered 11/1, 2017 at 7:1 Comment(0)
L
0

Let say you are in your tomcat folder as $TOMCAT_HOME

Step1:

on $TOMCAT_HOME/conf/tomcat-users.xml add the following line

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

with in:

   <tomcat-users.......

   </tomcat-users>

So it will looks like:

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

Step2:

and on $TOMCAT_HOME/webapps/manager/META-INF/context.xml : delete the following tag:

<Valve className=......

So it will be as:

<Context antiResourceLocking="false" privileged="true" >
  <!--
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
-->
</Context>

Final:

restart your tomcat

and you can find more details on Apache Tomcat 8 Manager App

Luke answered 6/8, 2017 at 16:51 Comment(0)
B
0

It actually helped me. You should try with a better(non guessable) username not like "Admin"

<role rolename="manager-gui"/>
<user username="TomcatAdmin" password="secpa55wd" roles="manager-gui"/>
Brandibrandice answered 25/4, 2020 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.