title: Problems deploying Spring 2 aplication in Apache Tomcat 6
body: <p>I'm trying to starting up with a Spring 2 + Struts 2 + Hibernate 3 arquitecture project, but I get an exception when deploy it in Apache Tomcat 6.0 within Eclipse (Helios version).</p>
  
  <p>Tomcat's exception on start:</p>
  
  <pre><code>GRAVE: Error configurando escuchador de aplicación de clase org.springframework.web.context.ContextLoaderListener
  java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
      at org.apache.catalina.core.StandardService.start(StandardService.java:519)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
  24-ago-2010 12:22:04 org.apache.catalina.core.StandardContext listenerStart
  GRAVE: Se ha saltado la instalación de escuchadores de aplicación debido a error(es) previo(s)
  24-ago-2010 12:22:04 org.apache.catalina.core.StandardContext start
  GRAVE: Error listenerStart
  24-ago-2010 12:22:04 org.apache.catalina.core.StandardContext start
  GRAVE: Falló en arranque del Contexto [/web] debido a errores previos
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app id="struts_blank" version="2.4"
      xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
      &lt;display-name&gt;Struts Blank&lt;/display-name&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath:spring.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;struts2&lt;/filter-name&gt;
          &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;struts2&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I googled it for a long time, and I tried some possible solutions that I found but they haven't worked.
  I'm going to explain what I tried and the exception obtained:</p>
  
  <p>First way: 
  In Tomcat server configuration, classpath tab, I added spring-web-2.5.1.jar (just the same used in the project) as external jar in Bootstrap Entries section. 
  Then when Apache triggers this exception when starts</p>
  
  <pre><code>GRAVE: Error configurando escuchador de aplicación de clase org.springframework.web.context.ContextLoaderListener
  java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
      at java.lang.ClassLoader.findBootstrapClass(Native Method)
      at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:900)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:314)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1560)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
      at org.apache.catalina.core.StandardService.start(StandardService.java:519)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
  24-ago-2010 12:42:36 org.apache.catalina.core.StandardContext listenerStart
  GRAVE: Se ha saltado la instalación de escuchadores de aplicación debido a error(es) previo(s)
  24-ago-2010 12:42:36 org.apache.catalina.core.StandardContext start
  GRAVE: Error listenerStart
  24-ago-2010 12:42:36 org.apache.catalina.core.StandardContext start
  GRAVE: Falló en arranque del Contexto [/web] debido a errores previos
  </code></pre>
  
  <p>So I added, in the same place and way, servlet-api-2.4.jar. Then I get the following exception:</p>
  
  <pre><code>INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
  java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
  Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
      at org.apache.catalina.core.StandardHost$MemoryLeakTrackingListener.lifecycleEvent(StandardHost.java:561)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4625)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
      at org.apache.catalina.core.StandardService.start(StandardService.java:519)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
      ... 6 more
  </code></pre>
  
  <p>Second way: 
  In classpath tab I add my project and I get the same exception posted earlier (java.lang.reflect.InvocationTargetException).</p>
  
  <p>Why doesn't Apache Tomcat read properly the project libraries? Maybe I'm overlooking something, or something is wrong at all.
  Could you please help me to solve it? I'll give all information you need for it. </p>
  
  <p>Any help will be welcome.</p>