title: NoClassDefFoundError: org/hibernate/boot/MetadataBuilder
body: <p>I want to add PostGIS to my Spring Boot project, so I added the following dependencies:</p>
  
  <pre class="lang-xml prettyprint-override"><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/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.gmoika&lt;/groupId&gt;
      &lt;artifactId&gt;GmoikaApi&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;GmoikaApi&lt;/name&gt;
      &lt;description&gt;GMoika project&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.3.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-rest&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;net.postgis&lt;/groupId&gt;
              &lt;artifactId&gt;postgis-jdbc&lt;/artifactId&gt;
              &lt;version&gt;2.1.7.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernatespatial&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-spatial-postgis&lt;/artifactId&gt;
              &lt;version&gt;1.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
      &lt;version&gt;4.3.11.Final&lt;/version&gt;
  &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.vividsolutions&lt;/groupId&gt;
              &lt;artifactId&gt;jts&lt;/artifactId&gt;
              &lt;version&gt;1.13&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;net.spy&lt;/groupId&gt;
              &lt;artifactId&gt;spymemcached&lt;/artifactId&gt;
              &lt;version&gt;2.12.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
              &lt;artifactId&gt;guava&lt;/artifactId&gt;
              &lt;version&gt;18.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-codec&lt;/groupId&gt;
              &lt;artifactId&gt;commons-codec&lt;/artifactId&gt;
              &lt;version&gt;1.8&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.ini4j&lt;/groupId&gt;
              &lt;artifactId&gt;ini4j&lt;/artifactId&gt;
              &lt;version&gt;0.5.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.mail&lt;/groupId&gt;
              &lt;artifactId&gt;mail&lt;/artifactId&gt;
              &lt;version&gt;1.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.rabbitmq&lt;/groupId&gt;
              &lt;artifactId&gt;amqp-client&lt;/artifactId&gt;
              &lt;version&gt;4.1.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;jaxen&lt;/groupId&gt;
              &lt;artifactId&gt;jaxen&lt;/artifactId&gt;
              &lt;version&gt;1.1.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
              &lt;artifactId&gt;gson&lt;/artifactId&gt;
              &lt;version&gt;2.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;eclipselink&lt;/artifactId&gt;
              &lt;version&gt;2.5.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;org.eclipse.persistence.jpa.modelgen.processor&lt;/artifactId&gt;
              &lt;version&gt;2.5.2&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
       &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;OSGEO GeoTools repo&lt;/id&gt;
              &lt;url&gt;http://download.osgeo.org/webdav/geotools&lt;/url&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;Hibernate Spatial repo&lt;/id&gt;
              &lt;url&gt;http://www.hibernatespatial.org/repository&lt;/url&gt;
          &lt;/repository&gt;
          &lt;!-- add JBOSS repository for easy access to Hibernate libraries --&gt;
  
      &lt;/repositories&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>I have the following error: </p>
  
  <pre class="lang-none prettyprint-override"><code>java.lang.Thread.run(Thread.java:745)
          Caused by: org.springframework.beans.factory.BeanCreationException: 
  
      Error creating bean with name 'entityManagerFactory' defined in class path 
       resource
  [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.c
    lass]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/MetadataBuilder
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
                  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
                  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
                  at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
                  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
                  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
                  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
                  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
                  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
                  at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
                  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
                  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
                  at com.gmoika.GmoikaApiApplication.main(GmoikaApiApplication.java:18)
                  ... 6 more
              Caused by: java.lang.NoClassDefFoundError: org/hibernate/boot/MetadataBuilder
                  at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54)
                  at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
                  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
                  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
  
  
  ... 22 moreenter code here
          Caused by: java.lang.ClassNotFoundException: org.hibernate.boot.MetadataBuilder
              at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
              ... 28 m    
  </code></pre>
  
  <p>Maybe its due to Hibernete versions. Error occured when I add PostGIS dependencies to my project. </p>