struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: ApplicationListener issue
Date Thu, 25 Sep 2008 07:45:21 GMT
Martín Mauri wrote:
> Hi all,
> I'm having an issue while implementing an App Listener for my App.
> Thing is that the ApplicationListener appears to be working fine, as from the logs I
can see that the contextInitialized method is being invoked.
> 
> Inside the method I do this call, same way as the Mailreader sample app does:
> 
> context.setAttribute(DATABASE_KEY, database);
> The problem comes when from my action:
> 
> public class MyAction extends ActionSupport implements ApplicationAware {
> 
> public DBConnector getDatabase() {
> 
> Map application = getApplication();
> 
> Object db = application.get(DATABASE_KEY);
> 
> ....
> 
> }
> 
> db is returning null, like if the object got lost somewhere...
> 
> here's the fragmen of my web.xml:
> 
> <listener>
> 
> <listener-class>
> 
> myApp.ApplicationListener
> 
> </listener-class>
> 
> </listener>
> 
> Any ideas?

1) there's something wrong in your implementation of ApplicationAware 
and/or your getApplication() method

2) the 'database' variable was null when you called setAttribute() in 
your listener

3) you have code somewhere which is overwriting the application-scope 
property with a null value after the listener initializes it

4) the value of DATABASE_KEY is different in the listener and the action

Those are the most obvious places to start. In fact, I can't think of 
anything else it could be unless there's something very funky going on, 
in which case I doubt it can be diagnosed through a mailing list...

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message