wood burning stoves 2.0*
The moose likes Servlets and the fly likes Filters initialized before context is ready Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filters initialized before context is ready" Watch "Filters initialized before context is ready" New topic
Author

Filters initialized before context is ready

Craig Fox
Greenhorn

Joined: Sep 05, 2011
Posts: 1
My application contains filters which each have a static SessionFactory variable set. This is instantiated in the init() method, like so:



The filters are declared in web.xml, and there are multiple hibernate.cfg.xml files, due to the app needing to connect to multiple databases. The hibernate configuration files all declare a session factory object with a name attribute intended to match the factoryJndiName mentioned above.

Here is an example of one of my filters.



When I try to deploy the app on Tomcat 6.032, it runs the init() method for each filter before the context has had a chance to store the JNDI names for each SessionFactory. This causes the following error when executing ctx.lookup.



How do I ensure that the context has the jndi names for the SessionFactories set up before Tomcat initializes the filters?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filters initialized before context is ready
 
Similar Threads
Struts2 integration with Spring Security
JSF 1.1 and Tomcat 6
Filter authentication won't display error page
Applying more than One Filters
Invalid url pattern for filter in web.xml