I've done some more digging on this and found that the shutdown method of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine class does not appear to ever be called. This means that the destroyForPort method is never called which leaves Jetty's bounded thread pool running, selecting on the listen port. I also found that when I manually call shutdown (as shown in my original example) the connector is closed before the server is stopped around line 359 of the JettyHTTPServerEngine. This is what appears to be causing the exceptions from NIO. Jetty is still selecting on the connector sockets when the connector is closed. >From a quick step through, it looks like calling stop on the Server will close >the connector internally so it doesn't have to be done as an extra step. Even >if it was done as an extra step, I think it should occur after the call to >stop() on the Server so it stops selecting on the connector socket.
Any ideas? Michael Pilone Senior Software Engineer Vangent, Inc. Blueprint Solutions (c) 703-969-7493 Updated email address: [EMAIL PROTECTED] Visit our new web site: www.vangent.com ________________________________ From: Pilone, Mike [mailto:[EMAIL PROTECTED] Sent: Mon 7/30/2007 8:36 AM To: [email protected] Subject: Application Hang at Exit with Simple Frontend Hello all, I was previously using XFire and I am moving my application over to CXF. Right now I am just prototyping some application features and I needed a quick solution for remote administration. The simple frontend/embedded Jetty solution was working really well for me with XFire, but I am having a problem in CXF. It appears that stopping the server in CXF is not shutting down the Jetty engine, which causes my application to hang because Jetty's threads are still blocking on the server socket accept. After a shutdown, I still see Thread [btpool0-0 - Acceptor0 [EMAIL PROTECTED]:10001] (Running). I have a simple test application pasted below that can reproduce the problem. At this point I had to add some calls to get the destination and cast it to a Jetty specific class to get things to exit. Is there a better way to do this? Is there something I'm not configuring correctly? Any help is appreciated. This is under Java 1.5 with CXF 2.0. Jetty is being included from the CXF libs directory. package org.mpilone.cxftest; import java.io.IOException; import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.ServerFactoryBean; public class CxfJettyTest { public void doIt() { System.out.println("Running test method"); } public static void main(String[] args) throws IOException { // Create an Service and Server ServerFactoryBean serverFactory = new ServerFactoryBean(); serverFactory.setServiceClass(CxfJettyTest.class); serverFactory.setServiceBean(new CxfJettyTest()); serverFactory.setAddress("http://localhost:10001/RemoteApi"); Server mServer = serverFactory.create(); mServer.start(); System.in.read(); mServer.stop(); // Adding these lines allows the application to exit, but // WARNING: EXCEPTION // java.nio.channels.ClosedChannelException // log statements are produced. // JettyHTTPDestination jettyDest = (JettyHTTPDestination) // mServer.getDestination(); // JettyHTTPServerEngine jettyEngine = (JettyHTTPServerEngine) // jettyDest.getEngine(); // jettyEngine.shutdown(); System.out.println("Exiting"); } } Michael Pilone Senior Software Engineer Vangent, Inc. Blueprint Solutions (c) 703-969-7493 Updated email address: [EMAIL PROTECTED] Visit our new web site: www.vangent.com **************************************************************************** This email may contain material confidential to Pearson. If you were not an intended recipient, please notify the sender and delete all copies. We may monitor email to and from our network. **************************************************************************** **************************************************************************** This email may contain material confidential to Pearson. If you were not an intended recipient, please notify the sender and delete all copies. We may monitor email to and from our network. ****************************************************************************
