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

匿名 (未验证) 提交于 2019-12-03 08:52:47

问题:

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.

回答1:

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 :

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 !



回答2:

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> 


回答3:

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



回答4:

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 


回答5:

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.



回答6:

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



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!