如何修复javax.persistence.Table.indexes()[Ljavax / persistence / Index?

时间:2019-07-17 09:12:15

标签: java tomcat8

我正在用JSF开发一个应用程序。 错误是:

Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
    at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1087)
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:767)
    at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
    at w7h5.h8.sf.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:26)
    at w7h5.h8.transaction.TransactionalModule.invoke(TransactionalModule.java:29)
    at abrain.web.common.bean.EditorView.test_post(EditorView.java:112)
    at abrain.web.common.bean.EditorView.setText(EditorView.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at javax.el.BeanELResolver.setValue(BeanELResolver.java:122)
    ... 43 more

此应用程序就像一个社交网络,当我要保存新帖子时会发生此错误。 提供此功能的方法是:

public void test_post(String testo, String username){

        W7H5 w7db = W7DBS.getInstance();
        Post post=new Post();
        Timestamp data=new Timestamp(System.currentTimeMillis());
        UtentiSocial creatore=new UtentiSocial();
        creatore.setUsername(username);
        post.setCreatore(creatore);

        post.setTesto(testo);
        post.setDatacreazione(data);
        post.setCancellato(false);

        w7db.savePost(post);


        System.out.println("eseguito: " + "testo: "+ testo + "username " + username + "data " + data);


    }

我试图创建一个Java类测试,以免传递Tomcat(版本8.5),并且一切正常,因此在服务器上运行应用程序时会出现问题。

我正在使用:

  • hibernate-commons-annotations-5.0.1.Final.jar
  • hibernate-core-5.1.0.Final.jar
  • hibernate-jpa-2.1-api-1.0.0.Final.jar
  • hibernate-spatial-5.1.0.Final.jar
  • hibernate-validator-5.2.4.Final.jar

  • java版本“ 1.8.0_31”
  • Java(TM)SE运行时环境(内部版本1.8.0_31-b13)
  • Java HotSpot(TM)64位服务器VM(内部版本25.31-b07,混合模式)

1 个答案:

答案 0 :(得分:0)

this is the code of interface table from javax.persistence.ja

this is the code of interface table from jpa-2.1.jar

第一个图像是javax.persistence.jar中接口Table的源代码。如您所见,没有方法indexes()

第二个图像是jpa-2.1.jar中接口Table的源代码。并且存在方法indexes()

在我看来,可能是您的类路径中同时存在两个jar,这会造成冲突。 当您调用javax.persistence.Table时,我们不知道它是javax.persistence.jar还是jp​​a-2.1.jar的接口。

查看您的类路径并删除javaxpersistence.jar,然后重试。