hyfsy / hot-refresh

Hot refresh the class on the production environment
Apache License 2.0
3 stars 0 forks source link

Util.getInstrumentation失败,jar包启动,本地直接main跑是好的 #3

Closed hyfsy closed 2 years ago

hyfsy commented 2 years ago

java.lang.RuntimeException: Failed to invoke install at com.hyf.hotrefresh.common.util.ReflectUtils.invokeMethod(ReflectUtils.java:46) at com.hyf.hotrefresh.core.util.InfrastructureJarClassLoader.getInstrumentation(InfrastructureJarClassLoader.java:132) at com.hyf.hotrefresh.core.util.Util.getInstrumentation(Util.java:37) at com.hyf.hotrefresh.core.install.CoreInstaller.install(CoreInstaller.java:34) at com.hyf.hotrefresh.core.install.CoreInstaller.(CoreInstaller.java:22) at com.hyf.hotrefresh.adapter.spring.config.HotRefreshEnableCondition.matches(HotRefreshEnableCondition.java:16) at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:225) at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:599) at org.springframework.context.annotation.ConfigurationClassParser.access$800(ConfigurationClassParser.java:110) at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:811) at java.util.ArrayList.forEach(Unknown Source) at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:808) at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:779) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:192) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) at com.zhiming.product.ZhimingProductApplication.main(ZhimingProductApplication.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.hyf.hotrefresh.common.util.ReflectUtils.invokeMethod(ReflectUtils.java:44) ... 35 more Caused by: java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@5778826f at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:613) at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:586) at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:538) ... 40 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.bytebuddy.agent.Attacher.install(Attacher.java:106) at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:608) ... 42 more Caused by: com.sun.tools.attach.AttachNotSupportedException: no providers installed at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:203) ... 48 more

hyfsy commented 2 years ago

ByteBuddy is loaded by app class loader, but tools.jar is loaded by infrastructure class loader, it's lead to ByteBuddy cannot find the com.sun.tools.attach.spi.AttachProvider SPI in tools.jar at execution time.

hyfsy commented 2 years ago

so we broken the parent delegate to fixed it, you can see d1333eaf for more details.