title: java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.JPAMetadataProvider
body: <p>i created new simple web app projected with hibernate 5 , Tomcat9 server. when run project it show following error. </p>
  
  <pre><code>  Exception
   javax.servlet.ServletException: Servlet execution threw an exception
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  
  
    Root Cause
    java.lang.NoSuchMethodError: 
    org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.&lt;init&gt; 
   (Lorg/hibernate/boot/spi/MetadataBuildingOptions;)V
  
   org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl
   .generateDefaultReflectionManager(MetadataBuilderImpl.java:741)
  
   org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl
   .&lt;init&gt;(MetadataBuilderImpl.java:714)
    org.hibernate.boot.internal.MetadataBuilderImpl.&lt;init &gt; 
    (MetadataBuilderImpl.java:126)
  
    org.hibernate.boot.MetadataSources.getMetadataBuilder
   (MetadataSources.java:135)
  org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:654)
  org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
  org.serv.Controller.doPost(Controller.java:45)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  </code></pre>
  
  <p>here is servlet which throws exception </p>
  
  <pre><code>    package org.serv;
  
      import java.io.IOException;
  
  
     import javax.servlet.ServletException;
     import javax.servlet.annotation.WebServlet;
     import javax.servlet.http.HttpServlet;
     import javax.servlet.http.HttpServletRequest;
     import javax.servlet.http.HttpServletResponse;
  
    import org.hibernate.HibernateException;
    import org.hibernate.Session;
     import org.hibernate.SessionFactory;
   import org.hibernate.cfg.Configuration;
   import org.pojo.PhoneBook;
  
  
  
   @WebServlet("/Controller")
  public class Controller extends HttpServlet {
  private static final long serialVersionUID = 1L;
  
  /**
   * @see HttpServlet#HttpServlet()
   */
  public Controller() {
      super();
      // TODO Auto-generated constructor stub
  }
  
  protected void doGet(HttpServletRequest request, HttpServletResponse response )throws ServletException, IOException{
  
      doPost(request,response);
  }
  
  
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
  PhoneBook book = new PhoneBook();
      book.setName(request.getParameter("name"));
      book.setPhone(Integer.parseInt( request.getParameter("number")));
      book.setAddress(request.getParameter("address"));
      try {
      SessionFactory sf = new Configuration().configure("/hibernate.cfg.xml").buildSessionFactory();
      Session sess = sf.openSession();
      sess.beginTransaction();
      sess.save(book);
      sess.close();
      }catch(HibernateException e ) {e.printStackTrace();System.err.println("Session problem ");}
  
  }//end doPost
  
  }//servlet
  </code></pre>
  
  <p>Here are library list which been listed.</p>
  
  <p><a href="https://i.stack.imgur.com/gWbv9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gWbv9.png" alt="enter image description here"></a></p>
  
  <p>and here is hibernate.cfg.xml file structure </p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='utf-8'?&gt;
  
       &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
    &lt;hibernate-configuration&gt;
  
  &lt;session-factory&gt;
  
      &lt;!-- Database connection settings --&gt;
      &lt;property 
     name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property 
    name="connection.url"&gt;jdbc:mysql://localhost:3306/stockdb&lt;/property&gt;
      &lt;property name="connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"&gt;&lt;/property&gt;
  
  
      &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
      &lt;!-- Disable the second-level cache  --&gt;
      &lt;property 
    name="cache.provider_class"&gt;org.hibernate.cache.internal.NoCacheProvider
   &lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
  
      &lt;!--  Name the Annotated Entity Class --&gt;
      &lt;mapping class= "org.pojo.Product"/&gt;
      &lt;mapping class= "org.pojo.Catagories"/&gt;
      &lt;mapping class= "org.pojo.ProductDetail"/&gt;
      &lt;mapping class= "org.pojo.Supplier"/&gt;
      &lt;mapping class= "org.pojo.Staff"/&gt;
      &lt;mapping class= "org.pojo.Customer"/&gt;
      &lt;mapping class= "org.pojo.PurchaseInvoice"/&gt;
      &lt;mapping class= "org.pojo.SaleInvoice"/&gt;
      &lt;mapping class= "org.pojo.Stock"/&gt;
      &lt;mapping class= "org.pojo.PhoneBook"/&gt;
  &lt;/session-factory&gt;
  
   &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I have been searched everywhere and also search stackover flow but didn't found solution.</p>