1

I'm developing an application in JSF. The error is:

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

This application is like a Social network and this error occurs when i want to save a new Post. The method that provide this function is:

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);


    }

i have tried to create a java class test for not passing thought Tomcat (version 8.5) and all work correctly, so the problem occurs when i run the application on server.

I am using:

  • 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

and

  • java version "1.8.0_31"
  • Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
  • Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
Marco
  • 77
  • 1
  • 12
  • What is the hibernate version you use ? – Ray Lloy Jul 17 '19 at 09:18
  • 1
    This does not seem to be JSF related. It simply fails to initialize the Hibernate SessionFactory. – Selaron Jul 17 '19 at 09:22
  • 1
    Possible duplicate of [NoSuchMethodError in javax.persistence.Table.indexes()\[Ljavax/persistence/Index](https://stackoverflow.com/questions/20734540/nosuchmethoderror-in-javax-persistence-table-indexesljavax-persistence-index) – Selaron Jul 17 '19 at 09:24
  • @Selaron unfortunately is not the same, i do not use sbt. – Marco Jul 17 '19 at 13:22
  • @RayLloy i have added more information in description – Marco Jul 17 '19 at 13:23
  • which java version do you use ? because according to [this article](https://developer.ibm.com/answers/questions/179449/problems-with-hibernate/), `indexes()` was added for JEE7 – Ray Lloy Jul 17 '19 at 14:17
  • @RayLloy i have added also this information, i am sorry for having omitted them first. – Marco Jul 17 '19 at 16:40
  • Is there an additional javax.persistence*.jar in your class path? (e.g. in WebApp or App Server lib folder) – Selaron Jul 17 '19 at 19:06
  • @Selaron no anyone – Marco Jul 17 '19 at 21:18

1 Answers1

0

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

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

The first image is the source code of interface Table from javax.persistence.jar. As you can see there is not the method indexes().

The second image is the source code of interface Table from jpa-2.1.jar. And there method indexes() is present.

In my opinion, may be you have both jars in your classpath and this create a conflict. when you call javax.persistence.Table we don't know if it is the interface from javax.persistence.jar or jpa-2.1.jar.

Look into your classpath and delete the javaxpersistence.jar, and try again.

Ray Lloy
  • 171
  • 12