日常踩坑-Could not load org.apache.catalina.loader.WebappClassLoader. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.

今天webapp项目预发布tomcat启动失败,检查tomcat/logs/catalina.xxxx.log发现如下错误

Nov 15, 2017 5:05:28 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load org.apache.catalina.loader.WebappClassLoader.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at ch.qos.logback.classic.spi.PackagingDataCalculator.bestEffortLoadClass(PackagingDataCalculator.java:239)
    at ch.qos.logback.classic.spi.PackagingDataCalculator.computeBySTEP(PackagingDataCalculator.java:138)
    at ch.qos.logback.classic.spi.PackagingDataCalculator.populateUncommonFrames(PackagingDataCalculator.java:113)
    at ch.qos.logback.classic.spi.PackagingDataCalculator.populateFrames(PackagingDataCalculator.java:105)
    at ch.qos.logback.classic.spi.PackagingDataCalculator.calculate(PackagingDataCalculator.java:57)
    at ch.qos.logback.classic.spi.ThrowableProxy.calculatePackagingData(ThrowableProxy.java:147)
    at ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:124)
    at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:440)
    at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:396)
    at ch.qos.logback.classic.Logger.error(Logger.java:559)
    at org.apache.zookeeper.ClientCnxn$1.uncaughtException(ClientCnxn.java:414)
    at java.lang.Thread.dispatchUncaughtException(Thread.java:1964)

看不出什么头绪,再检查tomcat/logs/localhost.xxxx.log文件显示如下错误

Caused by: java.lang.UnsupportedClassVersionError: com/***/service/impl/AccountServiceImpl : Unsupported major.minor version 52.0 (unable to load class com.***.service.impl.AccountServiceImpl)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2961)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:247)
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)
    ... 34 more

提示不支持52.0版本的的类,再次查看了下JDK各版本的对应关系

JDK 8.0 = 52
JDK 7.0 = 51
JDK 6.0 = 50
JDK 5.0 = 49
JDK 1.4 = 48
JDK 1.3 = 47
JDK 1.2 = 46
JDK 1.1 = 45

查看服务器jdk版本,发现软链接指向了1.7版本的jdk,修改软链接指向到1.8,再次启动,成功。

    原文作者:yuanzicheng
    原文地址: https://www.jianshu.com/p/b696c7f48d58
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞