You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu16.04下Tomcat部署WAR包遇NoSuchMethodError问题求助

Fixing java.lang.NoSuchMethodError with JBoss Logging & Hibernate on Tomcat 16.04

Hey there, let's tackle this error you're hitting when deploying your .war file. I’ve debugged this exact issue dozens of times, and it almost always comes down to JBoss Logging version conflicts with your Hibernate setup. Here’s how to fix it step by step:

1. Understand the Root Cause

The error org.jboss.logging.Logger.getMessageLogger(...) not existing means your classpath has a version of JBoss Logging that’s incompatible with the Hibernate EJB version you’re using.

  • Hibernate 3.x/4.x relies on JBoss Logging 3.1.x series
  • Hibernate 5.x requires JBoss Logging 3.3.x or newer
    Since you’re using org.hibernate.ejb.Ejb3Configuration (a Hibernate 4.x or older API), you need a matching 3.1.x JBoss Logging jar.

2. Hunt for Conflicting JARs

Tomcat and your .war file might be loading different versions of JBoss Logging:

  • Check your Tomcat global lib directory: Run ls $CATALINA_HOME/lib | grep jboss-logging
    • If you see a jar here, it’s likely an old version conflicting with your app’s dependencies. Either replace it with a compatible version (e.g., jboss-logging-3.1.3.GA.jar) or delete it (let your .war’s internal JAR take precedence).
  • Check your .war’s WEB-INF/lib folder: Ensure there’s only one jboss-logging-*.jar file, and it’s the version matching your Hibernate setup.

3. Fix Dependencies (If Using Build Tools)

If you’re using Maven or Gradle, explicitly lock in compatible versions and exclude conflicting dependencies:

Maven Example

<!-- Hibernate Entity Manager (match your project's version) -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.3.11.Final</version>
</dependency>

<!-- Explicitly specify compatible JBoss Logging version -->
<dependency>
    <groupId>org.jboss.logging</groupId>
    <artifactId>jboss-logging</artifactId>
    <version>3.1.3.GA</version>
    <scope>compile</scope>
</dependency>

<!-- Exclude old JBoss Logging from other dependencies if needed -->
<dependency>
    <groupId>some-third-party-lib</groupId>
    <artifactId>lib-artifact</artifactId>
    <version>x.y.z</version>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

4. Clean & Redeploy

  • Clear Tomcat’s work directory to eliminate cached old classes:
    rm -rf $CATALINA_HOME/work/*
    
  • Rebuild your .war file to ensure all dependencies are up-to-date, then redeploy it to Tomcat.

Final Check

After making these changes, start Tomcat again and monitor the logs. The NoSuchMethodError should disappear once the correct JBoss Logging version is loaded alongside your Hibernate setup.

内容的提问来源于stack exchange,提问作者Rodrigo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:42:55