Spring Webmvc NoClassDefFoundError for class 'ModelAndViewDefiningException'

断了今生、忘了曾经 提交于 2020-01-25 08:50:21

问题


I have looked into this similar post here: NoClassDefFoundError ModelAndViewDefiningException on spring+was8.5.5.13, but it had no solutions.

I have unpacked my war file, and unpacked a library within it to verify it does contain the class mentioned in the NoClassDefFoundError: spring-webmvc-4.3.6.RELEASE.jar contains org/springframework/web/servlet/ModelAndViewDefiningException.class.

These are all my spring-related dependencies:

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

The last one only containing the specified class "ModelAndViewDefiningException" in the NoClassDefFoundError.

I have scanned through the unpacked jar file using my bash script to verify that the ModelAndViewDefiningException does indeed exist.

#!/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

It does indeed exist, through my script above:

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

回答1:


This occurs because of maxed out file handles. This application runs on an Amazon instance production server, doing loads of volume. Running applications like Nginx, and some of our own applications.

That's why the JVM was unable to load in the class, because there weren't any file handles, hence the NoClassDefFoundError exception was being thrown.



来源:https://stackoverflow.com/questions/57374949/spring-webmvc-noclassdeffounderror-for-class-modelandviewdefiningexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!