githubcheng2978 opened a new issue, #12250: URL: https://github.com/apache/skywalking/issues/12250
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues. ### Apache SkyWalking Component Java Agent (apache/skywalking-java) ### What happened I use the taobao SDK, which contains the jar package for HTTP client and is a custom class to load all the classes in the jar package. An exception occurs。 the SDK customer class load code: package com.taobao.pac.sdk.cp.sar; import com.taobao.pac.sdk.cp.Logger; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.net.URLClassLoader; import java.util.Enumeration; import java.util.Properties; public class IClassLoader extends URLClassLoader { private static final String version = "1.0.0.5"; private static IClassLoader instance; private OpenClassLoader parent; private static final boolean isForceUpdate = false; private static final String standardClasspathConfigFile = "/sar/sar.properties"; private static final String standardClasspathDir = "/sar/jars/"; private static String workDir = System.getProperty("user.home"); private IClassLoader(URL[] urls) { this(urls, IClassLoader.class.getClassLoader()); } private IClassLoader(URL[] urls, ClassLoader parent) { super(urls, (ClassLoader)null); this.parent = new OpenClassLoader(parent); } public static synchronized IClassLoader getInstance() throws IOException { if (instance != null) { return instance; } else { instance = getInstance("/sar/sar.properties"); return instance; } } private static IClassLoader getInstance(String classpathConfigFile) throws IOException { Class clazz = IClassLoader.class; InputStream in = clazz.getResourceAsStream(classpathConfigFile); Properties config = new Properties(); String sarDir = workDir + "/sar/jars/".replace("/", File.separator) + "1.0.0.5" + File.separator; File sarDirFile = new File(sarDir); if (!sarDirFile.exists() && !sarDirFile.mkdirs()) { throw new RuntimeException("create sar dir fail:" + sarDir); } else { Logger.error("初始化sar目录:" + sarDirFile); IClassLoader var34; try { config.load(in); String content = config.getProperty("jars"); Logger.error("sar中jar包列表如下:" + content); String[] jars = content.split(";"); URL[] urls = new URL[jars.length]; for(int i = 0; i < jars.length; ++i) { String jarName = jars[i]; jarName = jarName.trim(); String resource = "/sar/jars/" + jarName; URL url = clazz.getResource(resource); if (url == null) { throw new RuntimeException("can't found resources:" + resource); } String urlStr = url.toString(); String jarFileName; if (urlStr.startsWith("wsjar:")) { jarFileName = urlStr.substring(2); url = new URL(jarFileName); } if (url.getProtocol().equals("jar")) { jarFileName = sarDir + jarName; File jarFile = new File(jarFileName); if (jarFile.exists()) { Logger.error("jar包已经存在:" + jarFileName); } else { jarFile.createNewFile(); InputStream jarIn = null; OutputStream jarOut = null; try { jarIn = clazz.getResourceAsStream(resource); jarOut = new FileOutputStream(jarFile); transfer(jarIn, jarOut); } catch (Exception var29) { Exception e = var29; throw new RuntimeException(e); } finally { if (jarIn != null) { jarIn.close(); } if (jarOut != null) { jarOut.flush(); jarOut.close(); } } Logger.error("jar包初始化成功:" + jarFileName); } url = jarFile.toURI().toURL(); } else { Logger.error("加载文件协议资源:" + resource); } Logger.error("加载url:" + url); urls[i] = url; } var34 = new IClassLoader(urls); } catch (IOException var31) { IOException e = var31; Logger.error("加载文件协议资源异常", e); throw e; } finally { if (in != null) { in.close(); } } return var34; } } private static void transfer(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[4096]; while(true) { int count = is.read(buf); if (count < 0) { return; } os.write(buf, 0, count); } } public Class<?> loadClass(String name) throws ClassNotFoundException { try { return super.loadClass(name); } catch (ClassNotFoundException var3) { return this.parent.loadClass(name); } } public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { try { return super.loadClass(name, resolve); } catch (ClassNotFoundException var4) { return this.parent.loadClass(name, resolve); } } public URL getResource(String name) { URL url = super.getResource(name); if (url == null) { url = this.parent.getResource(name); } return url; } public Enumeration<URL> getResources(String name) throws IOException { Enumeration[] tmp = new Enumeration[2]; Enumeration<URL> resources = super.getResources(name); tmp[0] = resources; if (this.parent != null) { Enumeration<URL> parentResources = this.parent.getResources(name); tmp[1] = parentResources; } return new CompoundEnumeration(tmp); } public InputStream getResourceAsStream(String name) { InputStream in = super.getResourceAsStream(name); return in != null ? in : this.parent.getResourceAsStream(name); } public static void setWorkDir(String workDir) { if (workDir != null && workDir.trim().length() >= 1) { if (workDir.endsWith(File.separator)) { workDir = workDir.substring(0, workDir.length() - 1); } IClassLoader.workDir = workDir; } else { throw new RuntimeException("非法sar包工作目录"); } } interface ConfigKey { String jars = "jars"; } } ` An exception occurs, main" java.lang.IllegalAccessError: tried to access class org.apache.http.impl.client.InternalHttpClient$$sw$auxiliary$8shium3 from class org.apache.http.impl.client.InternalHttpClient. If I prioritize using this SDK and there are no system exceptions, If I prioritize using the client of the application's built-in Apache, an exception occur ### What you expected to happen If I prioritize using this SDK and there are no system exceptions, If I prioritize using the client of the application's built-in Apache, an exception occur ### How to reproduce If I prioritize using this SDK and there are no system exceptions, If I prioritize using the client of the application's built-in Apache, an exception occur ### Anything else If I prioritize using this SDK and there are no system exceptions, If I prioritize using the client of the application's built-in Apache, an exception occur ### Are you willing to submit a pull request to fix on your own? - [X] Yes I am willing to submit a pull request on my own! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
