How to debug an area in Tomcat?

I set the scope parameter in the server.xml host section like this:

<Realm className="org.apache.catalina.realm.JDBCRealm" driverName="org.gjt.mm.mysql.Driver" connectionURL="jdbc:mysql://localhost:3306/test" connectionName="test" connectionPassword="test" userTable="users" userNameCol="user_name" userCredCol="user_pass" userRoleTable="user_roles" roleNameCol="user_role" /> 

Also in web.xml:

 <security-role> <role-name>ADMIN</role-name> </security-role> <security-constraint> <web-resource-collection> <web-resource-name>critical</web-resource-name> <url-pattern>/admin/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>ADMIN</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/login.jsp</form-login-page> <form-error-page>/error.jsp</form-error-page> </form-login-config> </login-config> 

And I have a database installed. However, when login.jsp is called, even I entered the correct password, I was redirected to error.jsp

I want to know if there is a way to find what is wrong during the process. Can I do this in Eclipse or any other tips that might solve the problem?

+7
source share
2 answers

Use the following procedure to get debugging information from Realm authentication steps.

When you define your kingdom, add debug = "9" to the definition.

You also need to add this to the logging.properties file:

 org.apache.catalina.realm.level = ALL org.apache.catalina.realm.useParentHandlers = true org.apache.catalina.authenticator.level = ALL org.apache.catalina.authenticator.useParentHandlers = true 

You may also need to add this to prevent log buffering. If you do, be sure to delete it after debugging is complete.

 1catalina.org.apache.juli.FileHandler.bufferSize = -1 

Now debug logs for areas should end in the catalina.out file.

+14
source

For others who discovered this problem, I found that for Tomcat 8.5.40 the following works:

 java.util.logging.ConsoleHandler.level = ALL org.apache.catalina.level = FINEST org.apache.catalina.realm.JNDIRealm.level = FINEST org.apache.catalina.realm.JNDIRealm.useParentHandlers = true 

The key fact, apparently, is that your registration goes through several levels of definitions and will be truncated first, which has a lower level, so you need to make sure that every bit through which it passes is FINEST or ALL.

Hope this saves someone time;)

Yang.

0
source

Source: https://habr.com/ru/post/924814/


All Articles