Using a variety of tutorials I found online and the documentation for o.a.c.startup.Tomcat, I created the following main method to start up an embedded Tomcat. I'm using 7.0.37 Tomcat JARs.
public static void main(String... arguments) throws Exception { Tomcat tomcat = new Tomcat(); tomcat.setBaseDir(".basedir"); tomcat.setPort(8973); tomcat.enableNaming(); tomcat.init(); tomcat.start(); System.out.println("X: " + tomcat.getConnector().getService().getContainer()); tomcat.getServer().await(); } The System.out.println is for debugging purposes, because I'm getting a NullPointerException. Obviously I'm doing something wrong, because about an hour of Googling turned up precisely zero results of anyone who's getting a NullPointerException in MapperListener#findDefaultHost. For some reason, it looks like a Container is never created. What gives? Here's the full output of running the JAR file: Mar 14, 2013 2:39:04 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8973"] Mar 14, 2013 2:39:04 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Tomcat Mar 14, 2013 2:39:04 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8973"] Mar 14, 2013 2:39:04 PM org.apache.catalina.core.StandardService startInternal SEVERE: Failed to start connector [Connector[HTTP/1.1-8973]] org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8973]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335) at com.ul.Bootstrap.main(Bootstrap.java:15) Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.connector.MapperListener@768debd] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.connector.Connector.startInternal(Connector.java:1022) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 6 more Caused by: java.lang.NullPointerException at org.apache.catalina.connector.MapperListener.findDefaultHost(MapperListener.java:252) at org.apache.catalina.connector.MapperListener.startInternal(MapperListener.java:104) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 8 more X: null --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org