struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martín Mauri <>
Subject Re: ApplicationListener issue
Date Fri, 26 Sep 2008 01:04:03 GMT
Hi Laurie,
I've checked all the points that you suggested, and I think that #3 could be 
a possibility.
The thing is that the database object is not null when I do the 
context.setAttribute(DATABASE_KEY, database); But in the Action that 
implements the ApplicationAware interface I did the following:
Inside the method that gets invoked I did: Map application = 
getApplication(); and it turned out to be that the application object is 
null. Am I missing something in the configuration files? Is it required to 
do an interceptor to transfer this object from the Application Listener to 
my Action class?

I'll appreciate your help,

Thank you.

----- Original Message ----- 
From: "Laurie Harper" <>
To: <>
Sent: Thursday, September 25, 2008 4:45 AM
Subject: Re: ApplicationListener issue

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


To unsubscribe, e-mail:
For additional commands, e-mail:

__________ Información de NOD32, revisión 3469 (20080924) __________

Este mensaje ha sido analizado con  NOD32 antivirus system

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message