NoSuchMethodError: org.jboss.logging.Logger.debugf

荒凉一梦 提交于 2019-11-27 15:17:10

hibernate-entitymanager brought in jboss-logging as a dependency, but it is not the most up-to-date version and does not have that method implemented. It looks like you do not need jboss-logging, so try excluding it:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.0.1.Final</version>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Or if it turns out that you need jboss-logging for hibernate, then add a later version of jboss-logging as an additional dependency.

<dependency>
    <groupId>org.jboss.logging</groupId>
    <artifactId>jboss-logging</artifactId>
    <version>3.3.0.Final</version>
</dependency>

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.

The method org.jboss.logging.Logger.debugf is only available in the jboss-logging version 3.3.0, if you have this dependency in your project also you have to check that your GlassFish server also have the same version. I had the same error message and I solved it replacing the jboss-logging.jar at the glassfish installation folder because this jar is a previous version and it does not have the needed method. For example, I have the jar in the following path:

C:\Program Files\glassfish-4.1.1\glassfish\modules\jboss-logging.jar

I deleted the old jar and I put the new jar with same name but with the version 3.3.0. Just restart the GlassFish server and it will take the new jar version and that's all.

This problem was caused by conflict in JBoss modules jars. Replacing the file jboss-logging with its latest version solved the problem for me. The file is in the folder modules\system\layers\base\org\jboss\logging\main

Also, you should replace the name of the jar in the file module.xml with the new jar name. The file is located in the same folder.

I found the steps at this article useful in resolving the error. http://sanjayingole.blogspot.in/2015/10/caused-by-javalangnosuchmethoderror.html

Steps to follow in short ( If using Eclipse ) --

  1. Check for ALL "jboss-logging" sub-dependencies in the dependency hierarchy in pom.xml, and exclude all those dependencies.

     <dependency> 
         <groupId>org.hibernate</groupId> 
         <artifactId>hibernate-entitymanager</artifactId> 
        <version>${hibernate.version}</version>
        <exclusions>            
            <exclusion>
                <artifactId>jboss-logging</artifactId>
                <groupId>org.jboss.logging</groupId>
            </exclusion>
        </exclusions>
     </dependency>
    
  2. Use the jboss-logging version which does have the method. As suggested on the link, 3.2.0.Final does.

     <dependency>
                <artifactId>jboss-logging</artifactId>
                <groupId>org.jboss.logging</groupId>            
                <version>3.2.0.Final</version>
     </dependency>
    
Randhir Singh

If you are using glassfish jersey then bean-validator comes as dependency and tomcat certainly try to load Logger class from there.

The bean-validator clas also contains Logger class in same package.

Exclude the jar should resolve the issue

<dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-spring3</artifactId>
            <version>2.24.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring-aop</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>bean-validator</artifactId>
                    <groupId>org.glassfish.hk2.external</groupId>
                </exclusion>
            </exclusions>
        </dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!