啟動tomcat7之后,運行正常,但是運行一段時間就會提示以下警告:
十二月 04, 2013 5:10:15 下午 org.apache.catalina.realm.LockOutRealm authenticate WARNING: An attempt was made to authenticate the locked user "tomcat"
雖然不影響程序的運行,但是后台控制台一直提示,所以上網搜索找出現這個現象的原因。
處理這個問題最有效的辦法是把tomcat的webappsx下,自帶的文件夾全刪除之后,問題解決。
也可以按一下方法解決:
原因:
由於tomcat-users.xml配置有誤導致的。
注:只是部分內容:
<role rolename="tomcat"/> <!-- <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> --> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="zhuo" password="zhuo" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
我把空行前半部分給注釋掉了。
<role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/>
解決辦法如下:
把空行注釋掉的配置放開后,如上的警告消失。
原因介紹
你的應用加了身份認證,有人(或者你自己,呵呵)試圖用manager用戶登陸你的應用,密碼輸入錯誤5次或者5次以上(缺省是5次),就會在日志中記錄警告信息,並鎖定並禁止該用戶的進一步登陸。以提醒你可能有人惡意猜測你的管理員密碼。是tomcat為了阻止brute-force攻擊(基於密碼加密的暴力破解法)的安全策略。
配圖
登陸用戶名和密碼在conf/tomcat-users.xml中配置
server.xml中的配置如下:
<!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <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>