title: spring hibernate maven project gets an nosuchmethod error InjectionMetadata
body: <p>I have an spring web service that uses hibernate to communicate with the postgres db this is an maven project. I was trying to get an json list when suddenly i got the following error:
  <h1>HTTP Status 500 - Servlet.init() for servlet appServlet threw exception</h1><p><b>type</b> Exception report</p><p><b>message</b> Servlet.init() for servlet appServlet threw exception</p><p><b>description</b> The server encountered an internal error that prevented it from fulfilling this request.</p><p><b>exception</b> <pre>javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      java.lang.Thread.run(Thread.java:744)
  </pre></p><p><b>root cause</b> <pre>java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.&lt;init&gt;(Ljava/lang/Class;)V
      org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:350)
      org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:296)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:830)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:493)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
      org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
      org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
      org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
      org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
      org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
      org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
      javax.servlet.GenericServlet.init(GenericServlet.java:160)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      java.lang.Thread.run(Thread.java:744)
  </pre></p><p><b>note</b> The full stack trace of the root cause is available in the Apache Tomcat/7.0.34 logs.</p><h3>Apache Tomcat/7.0.34</h3></p>
  
  <p>my web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Processes application requests --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>my servlet:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
          xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
                  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --&gt;
  
      &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
      &lt;annotation-driven /&gt;
  
      &lt;!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --&gt;
      &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
      &lt;!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --&gt;
      &lt;beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
          &lt;beans:property name="suffix" value=".jsp" /&gt;
      &lt;/beans:bean&gt;
      &lt;beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
              &lt;beans:property name="driverClassName" value="org.postgresql.Driver"/&gt;
              &lt;beans:property name="url" value="jdbc:postgresql://localhost:5432/tms"/&gt;
              &lt;beans:property name="username" value="postgres"/&gt;
              &lt;beans:property name="password" value="paswoord"/&gt;
          &lt;/beans:bean&gt;
  
          &lt;beans:bean id="sessionFactory"
              class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
              &lt;beans:property name="dataSource" ref="dataSource" /&gt;
              &lt;beans:property name="configLocation"&gt;
                  &lt;beans:value&gt;classpath:hibernate.cfg.xml&lt;/beans:value&gt;
              &lt;/beans:property&gt;
              &lt;beans:property name="configurationClass"&gt;
                  &lt;beans:value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/beans:value&gt;
              &lt;/beans:property&gt;
              &lt;beans:property name="hibernateProperties"&gt;
                  &lt;beans:props&gt;
                      &lt;beans:prop key="hibernate.dialect"&gt;${jdbc.dialect}&lt;/beans:prop&gt;
                      &lt;beans:prop key="hibernate.show_sql"&gt;true&lt;/beans:prop&gt;
                  &lt;/beans:props&gt;
              &lt;/beans:property&gt;
          &lt;/beans:bean&gt;
          &lt;tx:annotation-driven /&gt;
          &lt;beans:bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
              &lt;beans:property name="sessionFactory" ref="sessionFactory" /&gt;
          &lt;/beans:bean&gt;
      &lt;context:component-scan base-package="be.pxl.publictms" /&gt;
  
  
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>my pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;be.pxl&lt;/groupId&gt;
      &lt;artifactId&gt;publictms&lt;/artifactId&gt;
      &lt;name&gt;PublicTms&lt;/name&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0.0-BUILD-SNAPSHOT&lt;/version&gt;
      &lt;properties&gt;
          &lt;java-version&gt;1.6&lt;/java-version&gt;
          &lt;org.springframework-version&gt;3.1.1.RELEASE&lt;/org.springframework-version&gt;
          &lt;org.aspectj-version&gt;1.6.10&lt;/org.aspectj-version&gt;
          &lt;org.slf4j-version&gt;1.6.6&lt;/org.slf4j-version&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.9&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;additionalProjectnatures&gt;
                          &lt;projectnature&gt;org.springframework.ide.eclipse.core.springnature&lt;/projectnature&gt;
                      &lt;/additionalProjectnatures&gt;
                      &lt;additionalBuildcommands&gt;
                          &lt;buildcommand&gt;org.springframework.ide.eclipse.core.springbuilder&lt;/buildcommand&gt;
                      &lt;/additionalBuildcommands&gt;
                      &lt;downloadSources&gt;true&lt;/downloadSources&gt;
                      &lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.5.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                      &lt;compilerArgument&gt;-Xlint:all&lt;/compilerArgument&gt;
                      &lt;showWarnings&gt;true&lt;/showWarnings&gt;
                      &lt;showDeprecation&gt;true&lt;/showDeprecation&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.2.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;mainClass&gt;org.test.int1.Main&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;unknown-jars-temp-repo&lt;/id&gt;
              &lt;name&gt;A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.&lt;/name&gt;
              &lt;url&gt;file:${project.basedir}/lib&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;dependencies&gt;
          &lt;!-- Spring --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
  
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- AspectJ --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
              &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
              &lt;version&gt;${org.aspectj-version}&lt;/version&gt;
          &lt;/dependency&gt;   
  
          &lt;!-- Logging --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;version&gt;1.2.15&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;javax.mail&lt;/groupId&gt;
                      &lt;artifactId&gt;mail&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;javax.jms&lt;/groupId&gt;
                      &lt;artifactId&gt;jms&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;com.sun.jdmk&lt;/groupId&gt;
                      &lt;artifactId&gt;jmxtools&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;com.sun.jmx&lt;/groupId&gt;
                      &lt;artifactId&gt;jmxri&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- @Inject --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.inject&lt;/groupId&gt;
              &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
              &lt;version&gt;1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Servlet --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.1&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;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- jackson --&gt;
           &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-mapper-lgpl&lt;/artifactId&gt;
              &lt;version&gt;1.2.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Test --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.7&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
        &lt;artifactId&gt;hibernate&lt;/artifactId&gt;
        &lt;version&gt;3.2.5.ga&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;3.3.2.GA&lt;/version&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;javax.sql&lt;/groupId&gt;
        &lt;artifactId&gt;jdbc-stdext&lt;/artifactId&gt;
        &lt;version&gt;2.0&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&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.0.1B&lt;/version&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
        &lt;artifactId&gt;ejb3-persistence&lt;/artifactId&gt;
        &lt;version&gt;1.0.1.GA&lt;/version&gt;
       &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;unknown.binary&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql-9.2-1002.jdbc4&lt;/artifactId&gt;
              &lt;version&gt;SNAPSHOT&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;3.2.5.RELEASE&lt;/version&gt;
              &lt;type&gt;jar&lt;/type&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>And finally my controller, the methods work but when i use the getUsers method i get an http 500 error this is strange because the list is populated:</p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import be.pxl.publictms.model.Computer;
  import be.pxl.publictms.pojo.Gebruiker;
  import be.pxl.publictms.service.GebruikerService;
  import java.util.List;
  import org.springframework.beans.factory.annotation.Autowired;
  
  
  @Controller
  @RequestMapping("test")
  public class TestController {
  
      @Autowired
      private GebruikerService gebruikerService;
  
      @RequestMapping(value = "pc",method = RequestMethod.GET)
      public @ResponseBody Computer testMethod() {
          return new Computer(0, "DELL");
      }
  
      @RequestMapping(value = "users",method = RequestMethod.GET)
      public @ResponseBody List&lt;Gebruiker&gt; getUsers(){
          List&lt;Gebruiker&gt; users = gebruikerService.getGebruikers();
          System.out.println("***********************************************");
          for(Gebruiker user: users){
              System.out.println(user.toString());
          }
          System.out.println("***********************************************");
          /*List&lt;Gebruiker&gt; users = new ArrayList&lt;Gebruiker&gt;();
          users.add(new Gebruiker(1, "laurens", "test"));
          users.add(new Gebruiker(2, "laurens", "test"));
          users.add(new Gebruiker(3, "laurens", "test"));*/
          return users;
      }
  }
  </code></pre>