title: Error in eclipse, which does not occur outside the eclipse (using maven, strut2, hibernate4, spring3)
body: <p>I am developing a project with maven, strut2, hibernate4, spring3 and eclipse
  The application works perfectly when I copy the file ".War" to a install external of tomcat (Apache Tomcat Version 7.0.21), it is a installation of xampp.</p>
  
  <p>That is, the following process is working properly:
  "Run as" -> "Maven install"
  Copy the file ".War" located in the folder "target" of the project
  Paste the file in the folder
  "Tomcat \ webapps"
  Run the tomcat</p>
  
  <p>The problem arises when I try to run the application from the eclipse to: </p>
  
  <ul>
  <li>Save time</li>
  <li>Debug the application</li>
  <li>Work in a more comfortable environment</li>
  </ul>
  
  <p>I always get the following exception:</p>
  
  <pre><code>    2012-09-11 13:02:41,853 ERROR [ContextLoader.java:215] : Context initialization failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\Dropbox\web\mis proyectos\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\WIMP\WEB-INF\classes\applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
  Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
      at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:259)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
      ... 22 more
  Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
      ... 25 more
  sep 11, 2012 1:02:41 PM org.apache.catalina.core.StandardContext listenerStart
  Grave: Excepción enviando evento inicializado de contexto a instancia de escuchador de clase org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\Dropbox\web\mis proyectos\maven\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\WIMP\WEB-INF\classes\applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
  Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
      at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:259)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
      ... 22 more
  Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
      ... 25 more
  </code></pre>
  
  <p>It is an exception that apparently corresponds to Hibernate3, although the application uses hibernate4</p>
  
  <p>Besides that particularly bothers me when I do not use the eclipse the error does not occur, and using the eclipse itself (Tomcat v7.0 Server).</p>
  
  <pre><code>applicationContext.xml
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:util="http://www.springframework.org/schema/util"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/util  http://www.springframework.org/schema/util/spring-util-3.0.xsd
  http://www.springframework.org/schema/tx    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  http://www.springframework.org/schema/aop   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt;
  
      &lt;!-- Example of SAF2 action instantiated by Spring --&gt;
      &lt;bean id="helloWorldAction" class="org.com.WIMP.HelloWorldAction" scope="prototype"/&gt;
  
      &lt;!-- The singleton hibernate session factory --&gt;
      &lt;bean id="sessionFactory" scope="singleton" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Spring's hibernate transaction manager, in charge of making hibernate sessions/txns --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- So classes/functions with @Transactional get a hibernate txn --&gt;
      &lt;tx:annotation-driven /&gt;
  
      &lt;!-- Inject my business services class to the actions --&gt;&lt;!-- services.Services --&gt;
      &lt;bean id="services" class="org.com.WIMP.services.Services" scope="singleton"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  
  
  pom.xml
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;org.com&lt;/groupId&gt;
      &lt;artifactId&gt;WIMP&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;2.2.3&lt;/version&gt;
      &lt;name&gt;Struts 2 Starter&lt;/name&gt;
      &lt;url&gt;http://www.myComp.com&lt;/url&gt;
      &lt;description&gt;Struts 2 Starter&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;struts2.version&gt;${project.version}&lt;/struts2.version&gt;
          &lt;spring.version&gt;3.1.1.RELEASE&lt;/spring.version&gt;
          &lt;hibernate.version&gt;4.1.6.Final&lt;/hibernate.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;!-- Junit --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!--  Struts 2 --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.struts&lt;/groupId&gt;
              &lt;artifactId&gt;struts2-core&lt;/artifactId&gt;
              &lt;version&gt;${struts2.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.struts&lt;/groupId&gt;
              &lt;artifactId&gt;struts2-sitemesh-plugin&lt;/artifactId&gt;
              &lt;version&gt;${struts2.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.struts&lt;/groupId&gt;
              &lt;artifactId&gt;struts2-spring-plugin&lt;/artifactId&gt;
              &lt;version&gt;${struts2.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.struts&lt;/groupId&gt;
              &lt;artifactId&gt;struts2-config-browser-plugin&lt;/artifactId&gt;
              &lt;version&gt;${struts2.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Spring --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
              &lt;artifactId&gt;jta&lt;/artifactId&gt;
              &lt;version&gt;1.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Hibernate --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-c3p0&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- cglib --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;cglib&lt;/groupId&gt;
              &lt;artifactId&gt;cglib&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Servlet &amp; Jsp --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.4&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Jakarta Commons --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
              &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
              &lt;version&gt;1.1.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Dwr --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;uk.ltd.getahead&lt;/groupId&gt;
              &lt;artifactId&gt;dwr&lt;/artifactId&gt;
              &lt;version&gt;1.1-beta-3&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Log4j --&gt;
          &lt;dependency&gt;
                &lt;groupId&gt;log4j&lt;/groupId&gt;
            &lt;artifactId&gt;log4j&lt;/artifactId&gt;
            &lt;version&gt;1.2.16&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
        &lt;finalName&gt;WIMP&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                     &lt;source&gt;1.5&lt;/source&gt;
                     &lt;target&gt;1.5&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt;
                  &lt;version&gt;6.1.21&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;scanIntervalSeconds&gt;10&lt;/scanIntervalSeconds&gt;
                      &lt;scanTargets&gt;
                          &lt;scanTarget&gt;src/main/webapp/WEB-INF&lt;/scanTarget&gt;
                          &lt;scanTarget&gt;src/main/webapp/WEB-INF/web.xml&lt;/scanTarget&gt;
                          &lt;scanTarget&gt;src/main/resources/struts.xml&lt;/scanTarget&gt;
                          &lt;scanTarget&gt;src/main/resources/applicationContext.xml&lt;/scanTarget&gt;
                      &lt;/scanTargets&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                          &lt;wtpversion&gt;1.5&lt;/wtpversion&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>If you can help me I would appreciate it.</p>