[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Server.stop not propigating
|
Hi fellow Jetty users!
I am deploying a war in an embedded jetty instance. When jetty starts, the war file deploys just fine, and my ApplicationLifecycleListener beans get a ContextRefreshedEvent. However, when I stop the jetty Server, I don't get an ContextClosedEvent in my web app (which happens in a normal application server).
Below is the code I use to start and stop my jetty server. I create the jetty Server (using spring IOC), and launch it using some java code which gets called from a windows
service; all this seems to be working. When the windows service is stopped, it calls
--------------------
ClassPathXmlApplicationContext jettyCtx = new ClasspathApplicationContext(...);
Server jettyServer = (Server)jettyCtx.getBean("jettyServer");
jettyServer.start();
...
// invoked through JNI
public void onStop() {
jettyServer.stop();
jettyServer.join()
}
Here is my spring beans, showing the creation of the jetty server (omitted the connectors for brevity).
--------------------
<bean id="myAppContext" class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/myapp" />
<property name="war" value="${my.warfile}" />
<property name="extraClasspath" value="deploy/config" />
</bean>
<bean id="jettyServer" class="org.eclipse.jetty.server.Server">
<property name="handler" ref="myAppContext" />
<property name="gracefulShutdown" value="500" />
<property name="stopAtShutdown" value="true" />
</bean>
--------------------
My understanding (possibly wrong) is that Server.stop() will chain to the handler (a WebAppContext) which should invoke ServletContextListener.contextDestroyed() on spring's main delegating servlet -- however I did not see this so I tried calling stop() directly on my WebAppContext:
WebAppContext myAppCtx = (WebAppContext)jettyServer.getHandler();
myAppCtx.stop();
The first thing I noticed is that I get different behavior. Calling WebAppContext.stop() directly creates different log messages which seem right -- something logs that it is stopping my application, "/myapp Destroying Spring application <my servlet name>"; however I do not see any more output after this point -- I think that the VM actually crashes.
Question: Why does Server.stop() not chain to WebAppContext.stop()?
Question: What am I doing wrong?
-- Justin