arex-agent-java icon indicating copy to clipboard operation
arex-agent-java copied to clipboard

springboot application start with java -jar after attach arex-agent not work

Open lucas-myx opened this issue 1 year ago • 0 comments

java -jar springboot-test.jar after successful startup, then use attach to start the arex-agent, some class not transform by agent. because this way use SpringBoot LaunchedURLClassLoader load classes, such as org.springframework.web.servlet.DispatcherServlet, and SpringBoot LaunchedURLClassLoader not delegate to parent class loader, so AppClassLoader or arex-agent classloader unable to find org.springframework.web.servlet.DispatcherServlet, and not transform this class, or similar errors may occur as follows :

java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest
        at io.arex.inst.httpclient.apache.common.ApacheHttpClientHelper.ignoreRequest(ApacheHttpClientHelper.java:44)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:157)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)        
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)

In this case you can add to the start parameter -javaagent like this: java -javaagent:arex-agent.jar -jar springboot-test.jar

If you must use this attach method, you can pay attention to this issue and we will optimize it in the future.

lucas-myx avatar Jun 26 '23 13:06 lucas-myx