Hibernate 5 + Glassfish 4.1.1: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

前端 未结 3 1107
野的像风
野的像风 2021-01-18 18:57

When I add Hibernate 5 to my website, I can\'t get it to work in Glassfish 4.1.1. I always get an error

java.lang.NoSuchMethodError: org.jboss.logg

3条回答
  •  失恋的感觉
    2021-01-18 19:26

    In my case, I was running the Hibernate 5 with JPA annotations on tomcat and stop working when I changed to glassfish 4.1

    The error:

    hibernate.properties not found

    Make sure: src/main/resources/hibernate.cfg.xml exists

    And if you only have the dependency of hibernate-core, I was using hibernate-annotations and hibernate-common-annotations and it was creating conflict. The hibernate 5 doesnt need these two, I had read somewhere.Try to remove ;)

    After that a new error appears:

    java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

    The reason was the oldest jboss-logging.jar at: "YOUR_GLASSFISH_FOLDER/glassfish/modules"

    Why? The hibernate 5 has dependency with the newest version of jboss-logging, and the glassfish 4 uses the oldest version even if you declare inside your POM file the newest version. Actually I'm using:

    org.jboss.logging jboss-logging 3.3.0.Final

    Then I downloaded it and replace the old .jar inside the modules path and it back to work, I spent 2 days trying to solve that and I hope it helps some future issues =D

    I used this link to help me: https://medium.com/@mertcal/using-hibernate-5-on-payara-cc242212a5d6#.npq2hdprz

    Another solution, in my case, could be back to the last Hibernate 4 version (4.3.11.Final) but it is already too old in my opinion

提交回复
热议问题