cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kuhns, John" <>
Subject BaseContext in servlet
Date Tue, 15 Jun 2010 14:16:22 GMT
I am attempting to set a reference to a pojo containing some user info for use during updates/inserts.
On reading the documentation early on, 3.0RC1 or so, I believed I could use setUserProperty
and the context would be reused within a given session. However it appears that BaseContext.getThreadObjectContext()
does not return the same context ever. 

In my web.xml I have:

I then implemented HttpSessionAttributeListener in my class and used the following code within

	public void attributeAdded(HttpSessionBindingEvent arg0) {
		ObjectContext ctx = null;
			ctx = BaseContext.getThreadObjectContext();
		}catch(Exception e){}
		if(ctx != null){
			ctx.setUserProperty("myData", this);

The code gets hit and the property is set, but every subsequent call to BaseContext.getThreadObjectContext().getUserProperty("myData")
returns null. If I explicitly set the user property with every request, all works fine. Am
I missing something?

John Kuhns

View raw message