You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gregor Schneider <rc...@googlemail.com> on 2007/05/29 14:30:16 UTC

HttpSessionBindingListener not working

Hi guys,

I'm having a problem getting my HttpSessionBindingListener to work.

The listener gets initialized (System.out in the constructor of the
listener), however, neither valueBound nor valueUnbound gets called.

In my application, the code where I'm storing an attribute to the
session is this:

            hreq.getSession().setAttribute("user", aUserName);
            hreq.getSession().getServletContext().log("user " +
aUserName + " bound to session");

In my log-file is clearly stated that the user got bound to the session:

INFO TP-Processor3
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/SingleSignOnCLUE]
- user genre bound to session

This is the code of the listener:

package com.cr.web.sso;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

public class AuthenticationListener implements HttpSessionBindingListener {
	
	public AuthenticationListener() {
		super();
		System.out.println("Listener initiaized");
	}

	public void valueBound(HttpSessionBindingEvent anEvent) {
		HttpSession session = anEvent.getSession();
		String user = (String) session.getAttribute("user");
		session.getServletContext().log("User added: " + user);
		System.out.println("User added: " + user);
	}

	public void valueUnbound(HttpSessionBindingEvent anEvent) {
		HttpSession session = anEvent.getSession();
		String user = (String) session.getAttribute("user");
		session.getServletContext().log("User removed: " + user);
		System.out.println("User removed: " + user);
	}
}


And this is my deployment-descriptor:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<listener>
		<listener-class>
			com.cr.web.sso.AuthenticationListener
		</listener-class>
	</listener>
	<servlet>
		<servlet-name>SingleSignOn</servlet-name>
		<servlet-class>com.cr.web.sso.SingleSignOn</servlet-class>
		<init-param>
			<param-name>count_popups</param-name>
			<param-value>3</param-value>
		</init-param>
		<init-param>
			<param-name>popup_0</param-name>
			<param-value>/BMIWizardCLUE</param-value>
		</init-param>
		<init-param>
			<param-name>popup_1</param-name>
			<param-value>/RRWizardCLUE</param-value>
		</init-param>
		<init-param>
			<param-name>popup_2</param-name>
			<param-value>/HyperlipCLUE</param-value>
		</init-param>
		<security-role-ref>
			<role-name>clueuser</role-name>
			<!-- role name used in code -->
			<role-link>clueuser</role-link>
		</security-role-ref>		
	</servlet>
	<servlet-mapping>
		<servlet-name>SingleSignOn</servlet-name>
		<url-pattern>/SingleSignOn</url-pattern>
	</servlet-mapping>
    <error-page>
        <error-code>403</error-code>
        <location>/errorPages/403_CLUE.html</location>
	</error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/errorPages/404_CLUE.html</location>
	</error-page>
    <error-page>
        <error-code>408</error-code>
        <location>/errorPages/408_CLUE.html</location>
	</error-page>
    <error-page>
    	<exception-type>java.lang.Throwable</exception-type>
    	<location>/errorPages/generalError_CLUE.html</location>
	</error-page>
	<security-constraint>
    	<web-resource-collection>
    	<web-resource-name>Protected Area</web-resource-name>
			<url-pattern>/*</url-pattern>
     	</web-resource-collection>
		<!-- describes the valid roles for this app -->
      	<auth-constraint>
        	<role-name>clueuser</role-name>
    	</auth-constraint>
    </security-constraint>
    <login-config>
            <auth-method>FORM</auth-method>
            <realm-name>Clue4Bereich</realm-name>
            <form-login-config>

<form-login-page>/login_clue/loginForm.html</form-login-page>
                    <form-error-page>/login_clue/error.html</form-error-page>
            </form-login-config>
    </login-config>
	<security-role>
		<description>CLUE-Users</description>
		<role-name>clueuser</role-name>
	</security-role>
</web-app>

I'm realling losing the rest of my hair with this, therefore: Please
hurry with any suggestions b4 I'm getting bald ;)

TIA

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
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