title: Java: Testing web application on embedded Tomcat (Tomcat won't start)
body: <p>I'm trying to run Selenium tests on a web application which is deployed on an embedded Tomcat server. Basically I'm following this manual: <a href="http://www.hostettler.net/blog/2012/04/09/embedded-jee-web-application-integration-testing-using-tomcat-7/" rel="nofollow">http://www.hostettler.net/blog/2012/04/09/embedded-jee-web-application-integration-testing-using-tomcat-7/</a></p>
  
  <p>When I try to start the server with <code>tomcat.start()</code>, I get the following exception:</p>
  
  <pre><code>SEVERE: A child container failed during start
  java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
      at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
      at java.util.concurrent.FutureTask.get(Unknown Source)
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
      at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:801)
      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(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.ExceptionInInitializerError
      at     org.apache.catalina.startup.ContextConfig.createWebXmlDigester(ContextConfig.java:522)
      at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:843)
      at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:389)
      at     org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
      at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
      at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
      at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
      ... 7 more
  Caused by: java.lang.NullPointerException
      at org.apache.tomcat.util.descriptor.DigesterFactory.idFor(DigesterFactory.java:107)
      at org.apache.tomcat.util.descriptor.DigesterFactory.&lt;clinit&gt;    (DigesterFactory.java:59)
      ... 15 more
  
  feb 03, 2014 9:28:28 AM 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[Tomcat].StandardHost[localhost]]
          at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
          at java.util.concurrent.FutureTask.get(Unknown Source)
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
          at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
          at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
          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:341)
          at com.jardo.selenium_demo.IndexPageTest.setUp(IndexPageTest.java:91)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at     org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
      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(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused by: org.apache.catalina.LifecycleException: A child container failed during start
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
      at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:801)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      ... 7 more
  </code></pre>
  
  <p>I've noticed that this exception occurs only when I add a war to the server. If I add no war, it starts up correctly. Here is how I add my war:</p>
  
  <pre><code>tomcat.addWebapp(tomcat.getHost(), "/selenium_demo", "C:\Users\jardo\AppData\Local\Temp\tomcat_test\selenium_demo");
  </code></pre>
  
  <p>The war file is located at: <code>C:\Users\jardo\AppData\Local\Temp\tomcat_test\selenium_demo.war</code>.</p>
  
  <p>I have to admit that I'm not sure whether the parameters in method <code>addWebapp</code> are set correctly. I didn't find any documentation. Maybe if someone knew how to set the parameters, that would fix my problem.</p>