title: Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.Table; Error creating bean
body: <p>Can anyone help me with this one? I already tried different solutions posted here but nothing works.</p>
  <pre><code>APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  An attempt was made to call a method that does not exist. The attempt was made from the following location:
  
      org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1239)
  
  The following method did not exist:
  
      javax.persistence.Table.indexes()[Ljavax/persistence/Index;
  
  The calling method's class, org.hibernate.cfg.annotations.EntityBinder, was loaded from the following location:
  
      jar:file:/C:/Users/csatl/.m2/repository/org/hibernate/hibernate-core/5.6.5.Final/hibernate-core-5.6.5.Final.jar!/org/hibernate/cfg/annotations/EntityBinder.class
  
  The called method's class, javax.persistence.Table, is available from the following locations:
  
      jar:file:/C:/Users/csatl/Desktop/Facultate/An%203-sem2/SD/labs/lab2/lib/javax.persistence.jar!/javax/persistence/Table.class
      jar:file:/C:/Users/csatl/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/Table.class
      jar:file:/C:/Users/csatl/.m2/repository/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar!/javax/persistence/Table.class
      jar:file:/C:/Users/csatl/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar!/javax/persistence/Table.class
  
  The called method's class hierarchy was loaded from the following locations:
  
      javax.persistence.Table: file:/C:/Users/csatl/Desktop/Facultate/An%203-sem2/SD/labs/lab2/lib/javax.persistence.jar
  
  
  Action:
  
  Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.annotations.EntityBinder and javax.persistence.Table
  
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
      at ro.sd.firstapp.FirstAppApplication.main(FirstAppApplication.java:11)
  Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
      at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1239)
      at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:826)
      at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225)
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239)
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282)
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460)
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494)
      at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
      ... 16 more
  </code></pre>
  <p>Here is my pom.xml</p>
  <pre><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&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;2.6.4&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;ro.sd&lt;/groupId&gt;
      &lt;artifactId&gt;first-app&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;first-app&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;frontend-maven-plugin.version&gt;1.6&lt;/frontend-maven-plugin.version&gt;
          &lt;node.version&gt;v14.8.0&lt;/node.version&gt;
          &lt;yarn.version&gt;v1.12.1&lt;/yarn.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&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-crypto&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.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-validation&lt;/artifactId&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;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;version&gt;1.18.22&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&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;5.6.5.Final&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;5.6.5.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
  &lt;!--        &lt;dependency&gt;--&gt;
  &lt;!--            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;--&gt;
  &lt;!--            &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;--&gt;
  &lt;!--            &lt;version&gt;4.1.4.Final&lt;/version&gt;--&gt;
  &lt;!--        &lt;/dependency&gt;--&gt;
  &lt;!--        &lt;dependency&gt;--&gt;
  &lt;!--            &lt;groupId&gt;org.hibernate&lt;/groupId&gt;--&gt;
  &lt;!--            &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;--&gt;
  &lt;!--            &lt;version&gt;5.2.3.Final&lt;/version&gt;--&gt;
  &lt;!--        &lt;/dependency&gt;--&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
              &lt;version&gt;1.0.2&lt;/version&gt;
          &lt;/dependency&gt;
  &lt;!--        &lt;dependency&gt;--&gt;
  &lt;!--            &lt;groupId&gt;javax.persistence&lt;/groupId&gt;--&gt;
  &lt;!--            &lt;artifactId&gt;javax.persistence-api&lt;/artifactId&gt;--&gt;
  &lt;!--            &lt;version&gt;2.1&lt;/version&gt;--&gt;
  &lt;!--        &lt;/dependency&gt;--&gt;
  &lt;!--        &lt;dependency&gt;--&gt;
  &lt;!--            &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;--&gt;
  &lt;!--            &lt;artifactId&gt;hibernate-jpa-2.1-api&lt;/artifactId&gt;--&gt;
  &lt;!--            &lt;version&gt;1.0.0.Final&lt;/version&gt;--&gt;
  &lt;!--        &lt;/dependency&gt;--&gt;
  
      &lt;/dependencies&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;version&gt;${project.parent.version}&lt;/version&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p>The BeanCreationException is from my main class. I used a try catch.</p>
  <pre><code>package ro.sd.firstapp;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class FirstAppApplication {
  
      public static void main(String[] args) {
          try{
              SpringApplication.run(FirstAppApplication.class, args);
          }catch (Exception e)
          {
              e.printStackTrace();
          }
      }
  
  </code></pre>
  <p>I tried changing the env variables. I tried including more dependencies, delete dependencies. I don't know what's wrong.</p>
  <p>Here is my <strong>mvn dependency:tree</strong></p>
  <pre><code>[INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) @ first-app ---
  [INFO] ro.sd:first-app:jar:0.0.1-SNAPSHOT
  [INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.6.4:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:2.6.4:compile
  [INFO] |  |  +- org.springframework:spring-aop:jar:5.3.16:compile
  [INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.9.7:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.6.4:compile
  [INFO] |  |  +- com.zaxxer:HikariCP:jar:4.0.3:compile
  [INFO] |  |  \- org.springframework:spring-jdbc:jar:5.3.16:compile
  [INFO] |  +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
  [INFO] |  +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile
  [INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.6.2:compile
  [INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.6.2:compile
  [INFO] |  |  +- org.springframework:spring-orm:jar:5.3.16:compile
  [INFO] |  |  +- org.springframework:spring-context:jar:5.3.16:compile
  [INFO] |  |  +- org.springframework:spring-tx:jar:5.3.16:compile
  [INFO] |  |  +- org.springframework:spring-beans:jar:5.3.16:compile
  [INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.36:compile
  [INFO] |  \- org.springframework:spring-aspects:jar:5.3.16:compile
  [INFO] +- org.springframework.boot:spring-boot-starter:jar:2.6.4:compile
  [INFO] |  +- org.springframework.boot:spring-boot:jar:2.6.4:compile
  [INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.4:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.6.4:compile
  [INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.2.10:compile
  [INFO] |  |  |  \- ch.qos.logback:logback-core:jar:1.2.10:compile
  [INFO] |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.1:compile
  [INFO] |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
  [INFO] |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.36:compile
  [INFO] |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
  [INFO] |  +- org.springframework:spring-core:jar:5.3.16:compile
  [INFO] |  |  \- org.springframework:spring-jcl:jar:5.3.16:compile
  [INFO] |  \- org.yaml:snakeyaml:jar:1.29:compile
  [INFO] +- org.springframework.security:spring-security-crypto:jar:5.6.2:compile
  [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.6.4:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.6.4:compile
  [INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.1:compile
  [INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.1:compile
  [INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.13.1:compile
  [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.13.1:compile
  [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.1:compile
  [INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.13.1:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.6.4:compile
  [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.58:compile
  [INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.58:compile
  [INFO] |  +- org.springframework:spring-web:jar:5.3.16:compile
  [INFO] |  \- org.springframework:spring-webmvc:jar:5.3.16:compile
  [INFO] |     \- org.springframework:spring-expression:jar:5.3.16:compile
  [INFO] +- org.springframework.boot:spring-boot-starter-validation:jar:2.6.4:compile
  [INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.58:compile
  [INFO] |  \- org.hibernate.validator:hibernate-validator:jar:6.2.2.Final:compile
  [INFO] |     \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
  [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.6.4:test
  [INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.6.4:test
  [INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.6.4:test
  [INFO] |  +- com.jayway.jsonpath:json-path:jar:2.6.0:test
  [INFO] |  |  \- net.minidev:json-smart:jar:2.4.8:test
  [INFO] |  |     \- net.minidev:accessors-smart:jar:2.4.8:test
  [INFO] |  |        \- org.ow2.asm:asm:jar:9.1:test
  [INFO] |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
  [INFO] |  |  \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
  [INFO] |  +- org.assertj:assertj-core:jar:3.21.0:test
  [INFO] |  +- org.hamcrest:hamcrest:jar:2.2:test
  [INFO] |  +- org.junit.jupiter:junit-jupiter:jar:5.8.2:test
  [INFO] |  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
  [INFO] |  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
  [INFO] |  |  |  +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
  [INFO] |  |  |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
  [INFO] |  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
  [INFO] |  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
  [INFO] |  |     \- org.junit.platform:junit-platform-engine:jar:1.8.2:test
  [INFO] |  +- org.mockito:mockito-core:jar:4.0.0:test
  [INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.11.22:test
  [INFO] |  |  \- org.objenesis:objenesis:jar:3.2:test
  [INFO] |  +- org.mockito:mockito-junit-jupiter:jar:4.0.0:test
  [INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
  [INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
  [INFO] |  +- org.springframework:spring-test:jar:5.3.16:test
  [INFO] |  \- org.xmlunit:xmlunit-core:jar:2.8.4:test
  [INFO] +- org.projectlombok:lombok:jar:1.18.22:compile
  [INFO] +- mysql:mysql-connector-java:jar:8.0.28:runtime
  [INFO] +- org.hibernate:hibernate-core:jar:5.6.5.Final:compile
  [INFO] |  +- org.jboss.logging:jboss-logging:jar:3.4.3.Final:compile
  [INFO] |  +- javax.persistence:javax.persistence-api:jar:2.2:compile
  [INFO] |  +- net.bytebuddy:byte-buddy:jar:1.11.22:compile
  [INFO] |  +- antlr:antlr:jar:2.7.7:compile
  [INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:compile
  [INFO] |  +- org.jboss:jandex:jar:2.4.2.Final:compile
  [INFO] |  +- com.fasterxml:classmate:jar:1.5.1:compile
  [INFO] |  +- javax.activation:javax.activation-api:jar:1.2.0:compile
  [INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile
  [INFO] |  \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.6:compile
  [INFO] |     +- org.glassfish.jaxb:txw2:jar:2.3.6:compile
  [INFO] |     +- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
  [INFO] |     \- com.sun.activation:jakarta.activation:jar:1.2.2:runtime
  [INFO] +- org.hibernate:hibernate-entitymanager:jar:5.6.5.Final:compile
  [INFO] +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
  [INFO] \- javax.persistence:persistence-api:jar:1.0.2:compile
  </code></pre>