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

前端 未结 3 1104
野的像风
野的像风 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

    Try to clean glassfish osgi-cache folder in your domain. You can find details in this Payara github issue: https://github.com/payara/Payara/issues/554 (Payara is a fork of Glassfish with additional features, so basic mechanics remain the same as in Glassfish)

    0 讨论(0)
  • 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

    0 讨论(0)
  • 2021-01-18 19:27

    I had a similar issue, I was able to fix it by creating a glassfish-web.xml file in the WEB-INF directory. The contents of the file are shown below:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
    <glassfish-web-app>
         <class-loader delegate="false"/>
    </glassfish-web-app>
    

    This ensures that glassfish does not load it's internal libraries, but libraries from your project..

    0 讨论(0)
提交回复
热议问题