title: Getting a java.lang.NoSuchMethodError when trying to connect to Oracle via Hibernate
body: <p>I am building an application using Spring MVC and Hibernate. I have not integrated Hibernate with Spring yet (new to both), and wanted to ensure a session can be opened through Hibernate first.</p>
  
  <p>I created a simple function to test and currently <strong>receiving the following error</strong>:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoSuchMethodError:
    org.hibernate.integrator.internal.IntegratorServiceImpl.(Ljava/util/LinkedHashSet;Lorg/hibernate/boot/registry/classloading/spi/ClassLoaderService;)V</p>
  </blockquote>
  
  <p>My logs tell me that the error occurs when I try to use the <code>StandardServiceRegistryBuilder().applySettings()</code> function call.</p>
  
  <hr>
  
  <p>I have placed my sample function below that tries to create a connection (please note that it is void, and does not actually do anything within other than try to catch any exceptions)</p>
  
  <pre><code>public static void main (String [] args) {
          testHibernate();
      }
  public static void testHibernate() {
          try {
              String hibernateFilePath = "src/main/java/hibernate.cfg.xml";
              File hibernateFile = new File(hibernateFilePath);
              Configuration configuration = new Configuration().configure(hibernateFile);
              StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
              SessionFactory factory = configuration.buildSessionFactory(builder.build());
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <hr>
  
  <p>Here is my hibernate.cfg.xml file:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="connection.url"&gt;jdbc:oracle://servername.website.com:12345/dbname678&lt;/property&gt;
          &lt;property name="connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
          &lt;property name="connection.username"&gt;username&lt;/property&gt;
          &lt;property name="connection.password"&gt;password&lt;/property&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <hr>
  
  <p>File structure for my project:</p>
  
  <p><a href="https://i.stack.imgur.com/bK6mQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bK6mQ.png" alt="File Structure"></a></p>
  
  <hr>
  
  <p><strong>Thoughts on my approach</strong>: I understand that the error being thrown has to do with an issue related to how the functions are called. Typically a java.lang.NoSuchMethodError occurs when function Foo of library Bar is calling version 2.0 instead of 3.0. I double checked my dependencies and tried to rebuild the project yet I still face the same issue. I also tried IntelliJ's boilerplate code for Hibernate to test connections and still receive the exact same error.</p>