Daniel Wellman
2008-11-13 13:39:06 UTC
I have a question about how the WebappComposer works with request containers
that have components with lifecycle behaviors. Do request-scope components
support the Startable behavior in PicoWeb 2?
I've tried adding such a component to my WebappComposer but get an "Already
disposed" exception on my second HTTP request -- it fails when trying to
start the request-level Pico in PicoServletContainerFilter.
In the sample PicoWeb2 app using WebWork 2, I added a request-composed
component called RequestLogger, which implements Startable as below
public class RequestLogger implements Startable {
public void log(String message) {
System.out.println(new java.util.Date() + " " + message);
}
public void start() {
System.out.println(RequestLogger.class + " starting.");
}
public void stop() {
System.out.println(RequestLogger.class + " stopping.");
}
}
And I added RequestLogger to the CheeseInventory action to print a message.
I added the component to my WebappComposer's composeRequest() method.
When I run the application, the first request works as expected, but the
second request fails trying to start the request container with an "Already
disposed" exception.
First request works as expected:
class org.nanocontainer.nanowar.sample.RequestLogger starting.
Wed Nov 12 21:13:58 EST 2008 Found 1 cheeses.
class org.nanocontainer.nanowar.sample.RequestLogger stopping.
Second request prints:
Nov 12, 2008 9:14:07 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
java.lang.IllegalStateException: Already disposed
at org.picocontainer.behaviors.Stored.start(Stored.java:96)
at
org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:887)
at
org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:631)
at
org.picocontainer.web.PicoServletContainerFilter.doFilter(PicoServletContainerFilter.java:95)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)
When I debug, I find that in the second request's invoation of
DefaultPicoContainer's startAdapters() method, the list of Behaviors
includes my request object, which is marked as disposed but not started. I
trace through first request and find that indeed the component
is started, stopped, then disposed.
I'm using PicoWeb 2.1 with PicoContainer & Gems 2.6, using WebWork 2.1
(though the same behavior happens with WebWork 2.2) and Tomcat 5.5.
Thanks for your advice!
Cheers,
Dan
that have components with lifecycle behaviors. Do request-scope components
support the Startable behavior in PicoWeb 2?
I've tried adding such a component to my WebappComposer but get an "Already
disposed" exception on my second HTTP request -- it fails when trying to
start the request-level Pico in PicoServletContainerFilter.
In the sample PicoWeb2 app using WebWork 2, I added a request-composed
component called RequestLogger, which implements Startable as below
public class RequestLogger implements Startable {
public void log(String message) {
System.out.println(new java.util.Date() + " " + message);
}
public void start() {
System.out.println(RequestLogger.class + " starting.");
}
public void stop() {
System.out.println(RequestLogger.class + " stopping.");
}
}
And I added RequestLogger to the CheeseInventory action to print a message.
I added the component to my WebappComposer's composeRequest() method.
When I run the application, the first request works as expected, but the
second request fails trying to start the request container with an "Already
disposed" exception.
First request works as expected:
class org.nanocontainer.nanowar.sample.RequestLogger starting.
Wed Nov 12 21:13:58 EST 2008 Found 1 cheeses.
class org.nanocontainer.nanowar.sample.RequestLogger stopping.
Second request prints:
Nov 12, 2008 9:14:07 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
java.lang.IllegalStateException: Already disposed
at org.picocontainer.behaviors.Stored.start(Stored.java:96)
at
org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:887)
at
org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:631)
at
org.picocontainer.web.PicoServletContainerFilter.doFilter(PicoServletContainerFilter.java:95)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)
When I debug, I find that in the second request's invoation of
DefaultPicoContainer's startAdapters() method, the list of Behaviors
includes my request object, which is marked as disposed but not started. I
trace through first request and find that indeed the component
is started, stopped, then disposed.
I'm using PicoWeb 2.1 with PicoContainer & Gems 2.6, using WebWork 2.1
(though the same behavior happens with WebWork 2.2) and Tomcat 5.5.
Thanks for your advice!
Cheers,
Dan
--
View this message in context: http://www.nabble.com/PicoWeb%3A-%22Already-disposed%22-exception-with-Startable-request-scope-components-tp20480963p20480963.html
Sent from the NanoContainer - PicoContainer - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
View this message in context: http://www.nabble.com/PicoWeb%3A-%22Already-disposed%22-exception-with-Startable-request-scope-components-tp20480963p20480963.html
Sent from the NanoContainer - PicoContainer - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email