项目

一般

简介

分析思路 This web container has not yet been started

陈 泽豪将近 2 年 之前添加

应用反馈更新应用后,出现页面加载不出信息的问题

异常信息如下:
[2023-04-06T11:30:14] [] [INFO] [] [] [tid: _ThreadID=366 _ThreadName=ApusicLogManager] [timeMillis: 1680751814963] [levelValue: 800] [[
  2023-04-06 11:30:14,959 ERROR [org.jasig.services.persondir.RisePersonAttributeDao] - <This web container has not yet been started>
java.lang.IllegalStateException: This web container has not yet been started
    at com.apusic.aas.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1551)
    at com.apusic.aas.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:112)
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2592)
    at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:526)
    at org.springframework.data.mongodb.core.MongoTemplate.insertDocument(MongoTemplate.java:1270)
    at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:1051)
    at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:988)
    at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.insert(SimpleMongoRepository.java:247)
    at sun.reflect.GeneratedMethodAccessor1836.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377)
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:629)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:593)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
    at com.sun.proxy.$Proxy310.insert(Unknown Source)
    at com.huasisoft.portal.serviceImpl.LoginSTRecordServiceImpl.save(LoginSTRecordServiceImpl.java:24)
    at com.huasisoft.portal.serviceImpl.foreignService.DealLoginSTRecordServiceImpl.save(DealLoginSTRecordServiceImpl.java:58)
    at com.alibaba.dubbo.common.bytecode.Wrapper19.invokeMethod(Wrapper19.java)
    at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)
    at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76)
    at com.alibaba.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:52)
    at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
    at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:62)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:72)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:131)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:103)
    at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:96)
    at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:172)
    at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)
    at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:80)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
]]

分析思路:

1.根据日志第一层信息:
This web container has not yet been started 是 容器没有加载,初步这个看不出什么信息

2.接着堆栈信息最表层往下看:
com.apusic.aas.web.loader.WebappClassLoader.loadClass 这一段没什么用,主要是底层异常触发了,导致抛出This web container has not yet been started

3.接着看到:
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:112)
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2592)
    at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:526)
这里注意看到有mongodb,不要看到spring相关就忽视了

4.接着通过https://nowjava.com/jar/ 输入 org.springframework.data.mongodb.core.MongoExceptionTranslator 或 org.springframework.data.mongodb.core.MongoTemplate
 
找到并下载相应jar包,通过JD-GUI反编译分析
可以确定是spring-data-mongodb的jar包,但版本也要注意下,因为是通过类路径找的jar,日志堆栈信息中具体到了方法,所以要找到有对应方法名的jar包版本(translateExceptionIfPossiblepotentiallyConvertRuntimeExceptionexecute)
(最好找应用确定他们用的是什么版本,这样比较好找,这里我以为:spring-data-mongodb-2.1.1.RELEASE.jar)

5.通过IDEA或JD-GUI反编译jar包:
5.1 在jar中找到步骤3中的相关方法,可以看到execute的try中为异常导致代码,基本可以确定是mongodb的问题,
catch中potentiallyConvertRuntimeException是抛出的异常,是一个异常方法,调用了MongoExceptionTranslator异常类的translateExceptionIfPossible,不是最表层的异常,
如果需要分析为什么mongodb会抛出到This web container has not yet been started,而不是明显的mongodb的异常,就可以用arthas工具对potentiallyConvertRuntimeExceptiontranslateExceptionIfPossible方法监控,从而监控定位最表层的mongodb异常,因为从 translateExceptionIfPossible到com.apusic.aas.web.loader.WebongappClassLoader.loadClass 中间还会有其他相关具体mongodb信息,可以通过监控找到具体原因

6.arthas工具的监控使用:https://arthas.aliyun.com/doc/monitor.html