cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Hartmann <andr...@apache.org>
Subject Re: [2.2 servlet-service] Embedded servlet refreshed before it is initialized
Date Mon, 20 Jul 2009 16:09:10 GMT
Andreas Hartmann schrieb:
> Hi Cocoon devs,
> 
> I get an NPE in an embedded servlet (CXFServlet from Apache CXF) because 
> it references the servletConfig when onApplicationEvent() is processed. 
> Apparently this happens because the ServletFactoryBean calls
> 
>   container.refresh()
> 
> before
> 
>   this.embeddedServlet.init(blockServletConfig).
> 
> Does someone know how this relates to the servlet spec? Is the error on 
> the Cocoon side or on the CXF side? Can I change the order of the calls 
> as a workaround, or would this lead to unpredictable side effects?

Apparently the SitemapServlet relies on this execution order, i.e. it 
expects the WebApplicationContext to be set before init() is called:


java.lang.IllegalStateException: No WebApplicationContext found: no 
ContextLoaderListener registered?
	at 
org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:70)
	at 
org.apache.cocoon.servlet.RequestProcessor.<init>(RequestProcessor.java:89)
	at 
org.apache.cocoon.sitemap.SitemapServlet$RequestProcessor.<init>(SitemapServlet.java:98)
	at org.apache.cocoon.sitemap.SitemapServlet.init(SitemapServlet.java:74)
	at javax.servlet.GenericServlet.init(GenericServlet.java:241)


Would it make sense to use some kind of lazy loading here? Without 
further investigation it seems more reasonable to initialize the servlet 
before refreshing the context.

WDYT?

-- Andreas




-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


Mime
View raw message