Hibernate 5 java.lang.NoSuchMethodError org.jboss.logging.Logger.debugf

后端 未结 15 1829
天涯浪人
天涯浪人 2020-12-01 09:21

I have a problem when I deploy a webapp with hibernate 5

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


        
相关标签:
15条回答
  • 2020-12-01 09:49

    In all probability you've got an outdated JBoss Logging JAR on the application's classpath. The ...f methods are a relatively new addition to the Logger API. Hibernate 5 directly depends on Logging version 3.3.0, but it is possible that somehwere in your pom.xml you have an overriding dependency to an earlier version. Another possibility is that you are deploying to a JBoss container where the logging API is container-provided. Then you may need to upgrade the JBoss server, or introduce a workaround to prefer classes contributed by your application.

    0 讨论(0)
  • 2020-12-01 09:51

    In my case the culprit was the Jersey bean validator artifact. One of its dependencies, bean-validation-2.4.0-b06.jar contains Jboss logging classes, for some reason. I had to exclude the jersey-bean-validation and bean-validator artifacts from the spring-boot-starter-jersey dependency:

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>jersey-bean-validation</artifactId>
                    <groupId>org.glassfish.jersey.ext</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>bean-validator</artifactId>
                    <groupId>org.glassfish.hk2.external</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    

    EDIT: As of spring-boot 1.3.0, this is fixed and the exclusions above are not necessary anymore.

    0 讨论(0)
  • 2020-12-01 09:51

    I also faced with such kind of problem when deployed ear on weblogic server. Apparently, weblogic also use jboss logging system, and use old version of it.
    My fix:
    Add "weblogic-application.xml" to META-INF folder with this content:

        <?xml version="1.0" encoding="UTF-8"?>
        <weblogic-application>
            <prefer-application-packages>
                <package-name>org.jboss.logging.*</package-name>
            </prefer-application-packages>
    
            <prefer-application-resources>
                <resource-name>org/jboss/logging/Logger.class</resource-name>
            </prefer-application-resources>
        </weblogic-application>
    
    0 讨论(0)
提交回复
热议问题