Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 983
skiabox Avatar asked Jan 31 '13 13:01

skiabox


People also ask

How do I access Tomcat Manager?

Access the Apache Tomcat console by browsing to http://localhost:8080/ (if installed as a non-root user) or http://localhost/ (if installed as the root user).

Does Tomcat work with IntelliJ?

If you're not creating a new project from scratch and instead have an existing project that runs on Tomcat, you can configure IntelliJ IDEA Ultimate to connect to your existing Tomcat installation.

How do I access Tomcat 9 Admin GUI from another host?

By default the Host Manager is only accessible from a browser running on the same machine as Tomcat. If you wish to modify this restriction, you'll need to edit tomcat/webapps/manager/META-INF/context. xml to allow all ips or just yours.


1 Answers

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 !

like image 111
Ali.Ghodrat Avatar answered Oct 13 '22 20:10

Ali.Ghodrat