cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <dani...@nada.kth.se>
Subject [blocks] Intialization sequence question
Date Sun, 08 Oct 2006 11:14:55 GMT
A technical question for the Spring experts:

In the current implementation of the blocks fw the BlockServlet is a 
Spring managed component, but it gets init and destroy methods are 
called in the DispatcherServlet. After having fought a little bit more 
about it (and experienced some subtle initialization order problem that 
I had to hack around), I have realized that it not is such a good idea 
to let the DispatcherServlet have any part in the initialization. This 
is both from a SoC perspective and from the fact that the 
DispatcherServlet doesn't know anything about the dependency graph of 
the BlockServlet components.

The conclusion is that all setup of the BlockServlet should be performed 
by the Spring container. The natural way to do this seemed for me to let 
the BlockServlet implement the Spring interfaces: ServletConfigAware (so 
that it get the servlet config that the Spring web context uses) and 
InitializingBean and DisposableBean, for actually calling the Servlet 
init and destroy methods.

While trying that, the container is unhappy with the ServletConfigAware 
and says that it doesn't have any servlet config. Before trying to dig 
into exactly what happens, I would like to hear from the Spring experts 
(Carsten e.g.) if you have any idea about what I'm missing. Here is the 
stack trace:

Embedded error: Cannot invoke listener 
org.springframework.web.context.ContextLoaderListener@dcb6b4
Cannot satisfy ServletConfigAware for bean 
'org.apache.cocoon.ajax.block' without ServletConfig
[INFO] 
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Failure
         at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
         at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:488)
         at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:458)
         at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
         at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
         at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
         at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at 
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
         at 
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failure
         at 
org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:296)
         at 
org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:242)
         at 
org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:122)
         at 
org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:160)
         at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
         at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
         ... 16 more
Caused by: java.lang.RuntimeException: Cannot invoke listener 
org.springframework.web.context.ContextLoaderListener@dcb6b4
         at 
org.apache.cocoon.bootstrap.servlet.ShieldingListener.invoke(ShieldingListener.java:181)
         at 
org.apache.cocoon.bootstrap.servlet.ShieldingListener.contextInitialized(ShieldingListener.java:204)
         at 
org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:368)
         at 
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:957)
         at 
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:341)
         at 
org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:367)
         at 
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
         at 
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:101)
         at org.mortbay.jetty.Server.doStart(Server.java:235)
         at 
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
         at 
org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:114)
         at 
org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:285)
         ... 21 more
Caused by: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.apache.cocoon.ajax.block' defined in 
URL 
[file:C:/cygwin/usr/local/svn/cocoon-trunk/core/cocoon-webapp/target/cocoon-webapp/WEB-INF/cocoo
n/spring/cocoon-ajax-sample-blockServlet.xml]: Initialization of bean 
failed; nested exception is java.lang.IllegalStateException: Cannot 
satisfy ServletConfigAware for bean 'org.apache.cocoon.ajax.block' 
without ServletConfig
         at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:442)
         at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
         at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
         at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
         at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
         at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
         at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
         at 
org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
         at 
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
         at 
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
         at 
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
         at 
org.apache.cocoon.bootstrap.servlet.ShieldingListener.invoke(ShieldingListener.java:152)
         ... 32 more
Caused by: java.lang.IllegalStateException: Cannot satisfy 
ServletConfigAware for bean 'org.apache.cocoon.ajax.block' without 
ServletConfig
         at 
org.springframework.web.context.support.ServletContextAwareProcessor.postProcessBeforeInitialization(ServletContextAwareProcessor.java:90)
         at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanF
actory.java:297)
         at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1025)
         at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
         ... 43 more

Mime
View raw message