You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Troy Davis <tr...@metaphorstudio.com> on 2007/06/08 08:52:47 UTC

Problem with realm not displaying login form

Hello,

I'm having a problem with a realm setup that used to work under a  
previous version of Tomcat (5.5.9), but isn't now that I'm using  
5.5.23. For some reason it's not redirecting users to the login form  
upon first access of a protected URL setup in /WEB-INF/web.xml.

Instead they get the index.jsp page which they should see after  
logging in. The JSP has been processed, but an included header that  
loads an adminBean class does not show up, nor does a footer loading  
JspCalendar.class from /WEB-INF/classes/dates. Maybe it's correctly  
defending access to those classes when called from a jsp inside a  
security-constraint? The JspCalendar.class and a VisitorBean class  
are used in the public areas of the same site, no problem with them  
in that context.

Environment:
Tomcat 5.5.23
Fedora 4
latest apache 2.0 and mod_rewrite from fc rpms
rpm version of mysql as well
connectors 1.2.23

Note: I recently added +ForwardURIEscaped to /etc/httpd/conf.d/mod_jk- 
local.conf. Reading about this, I know that URL-based sessions won't  
work. But I don't think this is involved, and I disabled it with no  
effect on the realm issue, although my mod_rewrite rules failed as  
expected until I turned this option back on and restarted apache.

Any thoughts on how to troubleshoot this further?

Thank You,
Troy


 From server.xml:

<Host name="myclient.com" debug="99" appBase="webapps/myclient.com">
	<Alias>www.myclientfdncom</Alias>
	<Context path="/" docBase="" debug="99" reloadable="true">
		<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
		driverName="com.mysql.jdbc.Driver"
		connectionURL="jdbc:mysql://localhost/myclient"
		connectionName="myclient"
		connectionPassword="mypass"
		userTable="myapp_users"
		userNameCol="user_name"
		userCredCol="user_pass"
		userRoleTable="myapp_user_roles"
		roleNameCol="role_name"/>
	<WatchedResource>WEB-INF/web.xml</WatchedResource>
	</Context>
</Host>


WEB-INF/web.xml:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.com/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http:// 
java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
   version="2.4">

	<display-name>My Client</display-name>
	<description></description>
	<context-param>
		<param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
		<param-value>jdbc:mysql://localhost/myclient? 
autoReconnect=true,com.mysql.jdbc.Driver,myclient,mypass</param-value>
	</context-param>
	<security-constraint>
		<web-resource-collection>
			<web-resource-name>myapp Administration</web-resource-name>
			<url-pattern>/siteadmin/*</url-pattern>
			<http-method>DELETE</http-method>
			<http-method>GET</http-method>
			<http-method>POST</http-method>
			<http-method>PUT</http-method>
		</web-resource-collection>
		<auth-constraint>
			<role-name>myapp Admin</role-name>
		</auth-constraint>
		<user-data-constraint>
			<transport-guarantee>NONE</transport-guarantee>
		</user-data-constraint>
	</security-constraint>
	<login-config>
		<auth-method>FORM</auth-method>
		<realm-name>myapp Administration</realm-name>
		<form-login-config>
			<form-login-page>/login.jsp</form-login-page>
			<form-error-page>/login_fail.jsp</form-error-page>
		</form-login-config>
	</login-config>
	<security-role>
		<role-name>myapp Admin</role-name>
	</security-role>
	<filter>
		<filter-name>Set Character Encoding</filter-name>
		<filter-class>filters.SetCharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>Set Character Encoding</filter-name>
		<servlet-name>action</servlet-name>
	</filter-mapping>
</web-app>

from httpd.conf:

<VirtualHost *:80>
	DocumentRoot /usr/local/tomcat/webapps/myclient.com/
	ServerName myclient.com
	ServerAlias *.myclient.com
	DirectoryIndex index.jsp index.html index.cgi index.php
	CustomLog logs/myclient.com_access_log combinedcomp
	ErrorLog logs/myclient.com_error_log
	SetEnv AWSTATS_FORCE_CONFIG myclient.com
	ScriptAlias /cgi-bin/ /usr/local/tomcat/webapps/myclient.com/cgi-bin/
	<Directory /usr/local/tomcat/webapps/myclient.com/cgi-bin>
		Options ExecCGI
	</Directory>
	ScriptAlias /myapp/cgi-bin/ /usr/local/tomcat/webapps/myclient.com/ 
myapp/cgi-bin/
	<Directory /usr/local/tomcat/webapps/myclient.com/myapp/cgi-bin>
		Options ExecCGI
	</Directory>
	<Location "/WEB-INF/">
		deny from all
	</Location>
	RewriteEngine on
	RewriteCond "%{DOCUMENT_ROOT}/%{REQUEST_FILENAME}index.html" -f
	RewriteRule ^(.*)$ $1/index.html [L,R]
	RewriteCond "%{DOCUMENT_ROOT}/%{REQUEST_FILENAME}index.php" -f
	RewriteRule ^(.*)$ $1/index.php [L,R]
	RewriteCond "%{REQUEST_FILENAME}" !j_security_check
	RewriteCond "%{REQUEST_FILENAME}" !awstats
	RewriteCond "%{REQUEST_FILENAME}" !\.mvc
	RewriteCond "%{DOCUMENT_ROOT}/%{REQUEST_FILENAME}" !-f
	RewriteCond "%{DOCUMENT_ROOT}/%{REQUEST_FILENAME}" !-d
	RewriteRule ^(.*)$ /hru.jsp?hru=$1 [L,PT]
</VirtualHost>

/etc/httpd/conf.d/mod_jk-local.conf:

JkMount /*j_security_check ajp13
JkOptions +ForwardURIEscaped

/etc/httpd/conf.d/mod_jk.conf:

LoadModule      jk_module modules/mod_jk.so
JkWorkersFile   /etc/httpd/conf/workers.properties
JkLogFile       logs/mod_jk.log
JkLogLevel      error
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
Alias /examples "/usr/local/tomcat/webapps/examples"
<Directory "/usr/local/tomcat/webapps/examples">
     Options Indexes FollowSymLinks
</Directory>
JkMount /examples/servlet/* ajp13
JkMount /examples/*.jsp ajp13
<Location "/examples/WEB-INF/">
     deny from all
</Location>
Alias /tcadmin "/usr/local/tomcat/webapps/admin"
<Directory "/usr/local/tomcat/webapps/admin">
     Options Indexes FollowSymLinks
</Directory>
JkMount /admin/servlet/* ajp13
JkMount /admin/*.jsp ajp13
<Location "/admin/WEB-INF/">
     deny from all
</Location>
Alias /test "/usr/local/tomcat/webapps/test"
<Directory "/usr/local/tomcat/webapps/test">
     Options Indexes FollowSymLinks
</Directory>
JkMount /test/servlet/* ajp13
JkMount /test/*.jsp ajp13
<Location "/test/WEB-INF/">
     deny from all
</Location>
JkMount /jmx-console/* jboss
<Location "/jmx-console/">
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
</Location>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem with realm not displaying login form

Posted by Troy Davis <tr...@metaphorstudio.com>.
A follow-up on this issue: Downgrading to Tomcat 5.5.12 resolved the  
problem. What changes between .12 and .23 could cause this?

Thank You,
Troy


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org