Repository: hxsecurity/dongtai-agent-java
Issue: [Bug]: install成功后，原服务无法正常工作

### Preflight Checklist

- [X] I agree to follow the [Code of Conduct](https://github.com/HXSecurity/DongTai/blob/main/.github/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/HXSecurity/DongTai/issues) for an issue that matches the one I want to file, without success.
- [X] I am not looking for support or already pursued the available [support channels](https://github.com/HXSecurity/DongTai/issues/new/choose) without success.

### Version

1.4.0

### Installation Type

Official Docker Compose

### Service Name

DongTai-agent-java

### Describe the details of the bug and the steps to reproduce it

- docker run -d -p 8082:8080 --name springrce -it vulfocus/spring-core-rce-2022-03-29 这个镜像
- 用热部署的方法插入之后，服务器显示 500错误 `Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory` **（正常情况页面显示是OK）**

### Additional Information

_No response_

### Logs

```shell
02-Apr-2022 02:26:49.126 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 2 Spring WebApplicationInitializers detected on classpath
02-Apr-2022 02:26:50.801 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
02-Apr-2022 02:40:41.273 INFO [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring DispatcherServlet 'dispatcherServlet'
02-Apr-2022 02:40:41.444 SEVERE [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet [dispatcherServlet] threw exception
	java.lang.NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory
		at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
		at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3139)
		at java.base/java.lang.Class.getDeclaredMethod(Class.java:2430)
		at io.dongtai.iast.core.bytecode.enhance.plugin.spring.SpringApplicationImpl.loadApplicationContext(SpringApplicationImpl.java:41)
		at io.dongtai.iast.core.bytecode.enhance.plugin.spring.SpringApplicationImpl.getWebApplicationContext(SpringApplicationImpl.java:26)
		at io.dongtai.iast.core.handler.hookpoint.SpyDispatcherImpl.collectMethodPool(SpyDispatcherImpl.java:344)
		at org.springframework.web.servlet.FrameworkServlet.getWebApplicationContext(FrameworkServlet.java:806)
		at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
		at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
		at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
		at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:102)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:102)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
		at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:462)
		at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:388)
		at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.forwardToErrorPage(ErrorPageFilter.java:191)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.handleException(ErrorPageFilter.java:176)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:143)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
		at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
		at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
		at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
		at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
		at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
		at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
		at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:367)
		at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:639)
		at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
		at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:881)
		at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1647)
		at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
		at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
		at java.base/java.lang.Thread.run(Thread.java:844)
02-Apr-2022 02:40:41.452 SEVERE [http-nio-8080-exec-1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory] with root cause
	java.lang.NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory
		at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
		at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3139)
		at java.base/java.lang.Class.getDeclaredMethod(Class.java:2430)
		at io.dongtai.iast.core.bytecode.enhance.plugin.spring.SpringApplicationImpl.loadApplicationContext(SpringApplicationImpl.java:41)
		at io.dongtai.iast.core.bytecode.enhance.plugin.spring.SpringApplicationImpl.getWebApplicationContext(SpringApplicationImpl.java:26)
		at io.dongtai.iast.core.handler.hookpoint.SpyDispatcherImpl.collectMethodPool(SpyDispatcherImpl.java:344)
		at org.springframework.web.servlet.FrameworkServlet.getWebApplicationContext(FrameworkServlet.java:806)
		at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
		at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
		at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
		at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:102)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:102)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
		at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:462)
		at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:388)
		at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.forwardToErrorPage(ErrorPageFilter.java:191)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.handleException(ErrorPageFilter.java:176)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:143)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
		at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
		at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
		at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
		at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
		at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
		at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
		at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:367)
		at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:639)
		at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
		at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:881)
		at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1647)
		at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
		at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
		at java.base/java.lang.Thread.run(Thread.java:844)
```


Changed files:
dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/spring/SpringApplicationImpl.java

diff --git a/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/spring/SpringApplicationImpl.java b/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/spring/SpringApplicationImpl.java
index 682d9329..d1a91db6 100644
--- a/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/spring/SpringApplicationImpl.java
+++ b/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/spring/SpringApplicationImpl.java
@@ -37,6 +37,12 @@ public class SpringApplicationImpl {
                 getAPI = proxyClass.getDeclaredMethod("getAPI", Object.class);
             } catch (NoSuchMethodException e) {
                 DongTaiLog.error("SpringApplicationImpl.loadApplicationContext failed", e);
+            } catch (NoClassDefFoundError e) {
+                // spring mvc has no class org/springframework/beans/factory/ListableBeanFactory
+                if (!e.getMessage().equals(" org/springframework/beans/factory/ListableBeanFactory".substring(1))) {
+                    DongTaiLog.warn("SpringApplicationImpl.loadApplicationContext failed", e);
+                }
+                isSend = true;
             } finally {
                 iastClassLoader = null;
             }