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

Spring Boot 2 WAR部署Tomcat7时ELManager类缺失问题咨询

Fixing NoClassDefFoundError for javax/el/ELManager on Tomcat 7 with Spring Boot 2 + Gradle

Got it, let's work through this step by step. The core issue here is that Spring Boot 2's default Hibernate Validator 6.x requires EL 3.0, but Tomcat 7 only ships with EL 2.2. We need to align your dependencies to match Tomcat 7's environment without triggering classloader conflicts. Here's what to do:

1. Downgrade Hibernate Validator to support EL 2.2

Spring Boot 2 uses Hibernate Validator 6.x out of the box, which depends on EL 3.0. Since Tomcat 7 can't handle that, we need to roll back to Hibernate Validator 5.x (a stable version compatible with EL 2.2). Add this to your build.gradle to override the default version:

ext['hibernate-validator.version'] = '5.4.3.Final'

2. Align Tomcat dependencies to 7.0.76 and fix EL dependencies

You already set ext['tomcat.version'] = '7.0.76'—great start. Now we need to make sure we're using Tomcat 7's native EL libraries and exclude any conflicting embedded Tomcat EL dependencies:

First, confirm your WAR is configured for external Tomcat deployment (not executable) and mark the embedded Tomcat as provided:

plugins {
    id 'org.springframework.boot' version '2.7.x' // Stick to 2.7.x, it's the last Spring Boot 2 branch supporting Tomcat 7
    id 'war'
    id 'java'
}

war {
    enabled = true
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    
    // Mark embedded Tomcat as provided—we don't want it in our WAR
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
    
    // Exclude the embedded Tomcat EL JAR that comes with starter-web
    implementation('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-el'
    }
    
    // Add Tomcat 7's official EL API and implementation as provided (Tomcat already has these)
    providedRuntime 'org.apache.tomcat:tomcat-el-api:7.0.76'
    providedRuntime 'org.apache.tomcat:tomcat-el-impl:7.0.76'
}

3. Verify no conflicting dependencies

Run this Gradle command to check your dependency tree and ensure no EL 3.0 dependencies are lurking:

./gradlew dependencies

Search for javax.el or tomcat-el entries—you should only see versions matching 7.0.76, no 3.x versions of javax.el-api.

Quick Notes to Avoid Headaches

  • Stick to Spring Boot 2.7.x: Newer 2.x branches (like 2.8+) dropped support for Tomcat 7, so this is your safest bet.
  • Don't use generic javax.el-api: Tomcat 7 uses its own Apache-branded EL implementations, so using tomcat-el-api instead of the standard javax.el-api avoids classloader mismatches.
  • Check your WAR's lib folder: After building, make sure WEB-INF/lib doesn't contain tomcat-embed-el-*.jar or javax.el-api-3.x.jar—these would clash with Tomcat's native libraries.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 09:59:15