HendSame edited a comment on issue #3661:
URL: https://github.com/apache/skywalking/issues/3661#issuecomment-768278507


   I have a question: 
   Do you have to load the depency libs by "ExtClassLoader"?  @jackiepon31 
   
   "-Xbootclasspath/a:"  can  not  solve this problem?By the way ,we can use 
the BootstrapClassLoader to load the them.
   We  can run the oldWay.jar  such as: 
   
   ```
   java -javaagent:/{skywalking-agent-dir}/skywalking-agent-abm.jar
   -Xbootclasspath/a:/{your}.jar
   -Dskywalking.agent.service_name=serverName
   -Dskywalking.collector.backend_service=127.0.0.1:11800
   
   Maybe  multiple  jar  in one directory:
   
   java -javaagent:/{skywalking-agent-dir}/skywalking-agent-abm.jar
   -Xbootclasspath/a:/{jar-directory}
   -Dskywalking.agent.service_name=serverName
   -Dskywalking.collector.backend_service=127.0.0.1:11800
   ```
   
   If don't want to do that like the above 
   Just like @jackiepon31  said:
   “I suggest to add SkyWalking-agent.jar or its dirs to classpath to make the 
load mechanism compatible with old packaing way instead of spring-boot fat 
jar.” by using the  BootstrapClassLoader to load the them, rather than the 
ExtClassLoader ,is OK? @wu-sheng .Because ExtClassLoader can't seem to do it。
    We can use "instrumentation.appendToBootstrapClassLoaderSearch(jarFile)":
   ```
   public class SkyWalkingAgent {
           private static ILog LOGGER = 
LogManager.getLogger(SkyWalkingAgent.class);
           public static void premain(String agentArgs, Instrumentation 
instrumentation) throws PluginException {
                File basePath = AgentPackagePath.getPath();
                File classPathDictionary = new File(basePath, "classpath");
                if (classPathDictionary.exists() && 
classPathDictionary.isDirectory()) {
                       String[] jarFileNames = classPathDictionary.list((dir, 
name) -> name.endsWith(".jar"));
                       for (String fileName : jarFileNames) {
                           JarFile jarFile = new JarFile(classPathDictionary + 
"/" + fileName);
                           
instrumentation.appendToBootstrapClassLoaderSearch(jarFile);
                       }
                 }
          //.......
         }
   ```
   "classpath" is a dictionary that has the jars which need  to load to  
classpath;
   ```
   skywalking
         -- classpath
              -- 1.jar
              -- 2.jar
         -- skywalking-agent-abm.jar
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to