Spring class 'ModelAndViewDefiningException' 的 Webmvc NoClassDefFoundError

Spring Webmvc NoClassDefFoundError for class 'ModelAndViewDefiningException'

我已经在此处查看了类似的 post:NoClassDefFoundError ModelAndViewDefiningException on spring+was8.5.5.13,但没有解决方案。

我解压了我的 war 文件,并解压了其中的一个库以验证它是否包含 NoClassDefFoundError 中提到的 class: spring-webmvc-4.3.6.RELEASE.jar 包含 org/springframework/web/servlet/ModelAndViewDefiningException.class.

这些都是我的 spring 相关依赖项:

lib/metrics-spring-3.1.0 2 2.jar
lib/metrics-spring-3.1.0 2 3.jar
lib/metrics-spring-3.1.0 2.jar
lib/metrics-spring-3.1.0 3.jar
lib/metrics-spring-3.1.0.jar
lib/micrometer-spring-legacy-1.1.0.jar
lib/spring-aop-4.3.6.RELEASE.jar
lib/spring-aspects-4.3.6.RELEASE.jar
lib/spring-beans-4.3.6.RELEASE.jar
lib/spring-boot-2.1.1.RELEASE.jar
lib/spring-boot-actuator-2.1.1.RELEASE.jar
lib/spring-boot-actuator-autoconfigure-2.1.1.RELEASE.jar
lib/spring-boot-autoconfigure-2.1.1.RELEASE.jar
lib/spring-boot-starter-2.1.1.RELEASE.jar
lib/spring-boot-starter-actuator-2.1.1.RELEASE.jar
lib/spring-boot-starter-logging-2.1.1.RELEASE.jar
lib/spring-cloud-aws-autoconfigure-2.0.1.RELEASE.jar
lib/spring-cloud-aws-context-2.0.1.RELEASE.jar
lib/spring-cloud-aws-core-2.0.1.RELEASE.jar
lib/spring-cloud-starter-aws-2.0.1.RELEASE.jar
lib/spring-context-4.3.6.RELEASE.jar
lib/spring-context-support-4.1.6.RELEASE.jar
lib/spring-core-4.3.6.RELEASE.jar
lib/spring-data-commons-1.12.7.RELEASE.jar
lib/spring-data-jpa-1.10.7.RELEASE.jar
lib/spring-expression-4.3.6.RELEASE.jar
lib/spring-jdbc-4.3.6.RELEASE.jar
lib/spring-orm-4.3.6.RELEASE.jar
lib/spring-security-core-4.0.2.RELEASE.jar
lib/spring-test-4.3.6.RELEASE.jar
lib/spring-tx-4.3.6.RELEASE.jar
lib/spring-web-4.3.6.RELEASE.jar
lib/spring-webmvc-4.3.6.RELEASE.jar

NoClassDefFoundError 中最后一个只包含指定的class "ModelAndViewDefiningException"。

我已经使用我的 bash 脚本扫描了解压后的 jar 文件,以验证 ModelAndViewDefiningException 确实存在。

#!/bin/bash

for filename in lib/*spring*.jar; do
    x=`jar -tvf "$filename" | grep 'ModelAndViewDefiningException'`
    if test ! -z "$x" 
    then
      echo $filename " class found is: " $x
    fi
done

它确实存在,通过我上面的脚本:

lib/spring-webmvc-4.3.6.RELEASE.jar  class found is:  854 Wed Jan 25 13:16:28 AEDT 2017 org/springframework/web/servlet/ModelAndViewDefiningException.class
ip-192-168-0-13:WEB-INF

这是因为文件句柄已满。此应用程序在 Amazon 实例生产服务器上运行,处理大量负载。 运行 应用程序,如 Nginx,以及我们自己的一些应用程序。

这就是 JVM 无法在 class 中加载的原因,因为没有任何文件句柄,因此抛出了 NoClassDefFoundError 异常。