Hello all, I have an existing server which uses the Embedded class which I am tasked with upgrading to tomcat7 (deprecated, but we'll be keeping it for the time being). There were some small changes to the code to fix API breaks but the startup stuff is the same. When I start up the container I am now seeing this -
INFO: Starting tomcat server org.apache.catalina.startup.Embedded||Dec 7, 2012 12:09:49 PM org.apache.catalina.startup.Embedded startInternal INFO: Catalina naming disabled Dec 7, 2012 12:09:49 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.32 Dec 7, 2012 12:09:49 PM org.apache.catalina.util.LifecycleBase start INFO: The start() method was called on component [Realm[NullRealm]] after start() had already been called. The second call will be ignored. org.apache.catalina.util.LifecycleBase||Dec 7, 2012 12:09:49 PM org.apache.catalina.util.LifecycleBase start Dec 7, 2012 12:09:49 PM org.apache.catalina.core.ContainerBase startInternal SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[OSGiEngine].StandardHost[tomcathost].StandardContext[]] at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222) at java.util.concurrent.FutureTask.get(FutureTask.java:83) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:743) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[OSGiEngine].StandardHost[tomcathost].StandardContext[]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ... 7 more Caused by: java.lang.NullPointerException: while trying to invoke the method org.apache.catalina.Service.findConnectors() of an object loaded from local variable 's' at org.apache.catalina.core.ApplicationContext.populateSessionTrackingModes(ApplicationContext.java:1191) at org.apache.catalina.core.ApplicationContext.<init>(ApplicationContext.java:125) at org.apache.catalina.core.StandardContext.getServletContext(StandardContext.java:2323) at org.apache.catalina.core.StandardContext.postWorkDirectory(StandardContext.java:6062) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5102) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 7 more org.apache.catalina.core.ContainerBase||Dec 7, 2012 12:09:49 PM org.apache.catalina.core.ContainerBase startInternal I looked into that particular line in ApplicationContext and I see this code is new in tomcat7 - Service s = ((Engine) context.getParent().getParent()).getService(); Connector[] connectors = s.findConnectors(); Looking at the API docs for Engine, it indicates that a Service does not necessarily need to be associated with an Engine (from the docs - "Set the Service with which we are associated (if any). "). Am I missing a step now to prevent this? Or should there be a null check here? Thank you!