I'm trying to use tomcat 6.0.26, when I invoked start, it just quit silently instead of waiting there for http request. Does anyone have ideas?
package mytest; import java.io.File; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.UnknownHostException; import java.util.Properties; import org.apache.catalina.Context; import org.apache.catalina.Engine; import org.apache.catalina.Host; import org.apache.catalina.LifecycleException; import org.apache.catalina.core.StandardContext; import org.apache.catalina.loader.WebappLoader; import org.apache.catalina.realm.MemoryRealm; import org.apache.catalina.startup.Embedded; import org.apache.log4j.Logger; public class EmbedWebServer { private static final Logger logger = Logger.getLogger(EmbedWebServer.class); public static void main(String[] args) { try { new EmbedWebServer(); } catch (Exception t) { t.printStackTrace(); } } private Embedded tomcat; private String catalinaHome; private String projectHome; public EmbedWebServer() { initConf(); tomcat = new Embedded(); tomcat.setName("Catalina"); Engine engine = tomcat.createEngine(); engine.setDefaultHost("localhost"); Host host = tomcat.createHost("localhost", projectHome); Context ctx = tomcat.createContext ( "/", "mywebapp"); ctx.setReloadable(true); ((StandardContext) ctx).setWorkDir(System.getProperty("java.io.tmpdir") + "/jakarta-tomcat/work"); host.addChild(ctx); engine.addChild(host); engine.setName("Catalina"); tomcat.addEngine(engine); tomcat.addConnector(tomcat.createConnector((java.net.InetAddress) null, 8080, false)); registerShutdownHook(); try { tomcat.start(); } catch (Exception e) { logger.error(e); e.printStackTrace(); throw new RuntimeException(e); } } private void initConf() { Properties properties = new Properties(); try { properties.load(EmbedWebServer.class .getResourceAsStream("/tomcat-conf.properties")); catalinaHome = properties.getProperty("catalina.home"); File f = new File("."); projectHome = f.getAbsolutePath(); } catch (IOException e) { throw new RuntimeException(e); } } private void registerShutdownHook() { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { tomcat.stop(); } catch (LifecycleException e) { throw new RuntimeException(e); } } }); } } -- View this message in context: http://old.nabble.com/when-I-use-embedded-tomcat%2C-after-start-embedded%2C-the-tomcat-just-quit-silently-tp28544175p28544175.html Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org