On 1/19/2011 4:17 AM, Ivan wrote:
Hi,
From Tomcat 7.0.6, a different thread is used for listener start,
filter start, and loadOnStartup, the purpose for that is for avoiding
potential memory leaking. But we got problems for OWB initialization,
as we register a OWB listener in the context. I am not sure whether
this issue is a common issue, but so far, I could only see that OWB is
affected. Now, my idea is to save the webbeans context in the servlet
context, then attach it with the thread in
WebBeansConfigurationListener. Part of those codes are like :
--->
WebBeansContext oldWebBeansContext =
GeronimoSingletonService.contextEntered((WebBeansContext)event.getServletContext().getAttribute("org.apache.webbeans.config.WebBeansContext"));
try {
this.webBeansContext = WebBeansContext.getInstance();
this.failoverService =
webBeansContext.getService(FailOverService.class);
// this.lifeCycle.startApplication(event);
event.getServletContext().setAttribute(OpenWebBeansConfiguration.PROPERTY_OWB_APPLICATION,
"true");
} catch (Exception e) {
logger.error(OWBLogConst.ERROR_0018,
event.getServletContext().getContextPath());
WebBeansUtil.throwRuntimeExceptions(e);
} finally {
GeronimoSingletonService.contextExited(oldWebBeansContext);
}
<---
Not sure that there is a common solution for it. Thoughts ?
Saving the information needed by the listener in the servlet context
seems like a much cleaner solution than relying on the thread context.
If this is the only piece that is an issue, I'd go with the simple
solution. If there are other contexts that need to be accessed, then I
think these should be wrappered in a single Geronimo context object that
would be anchored in the servlet context.
Rick
Thanks.
--
Ivan