Прошу прощения за длинный пост, но, на мой взгляд, он необходим для правильного понимания проблемы
Context
I 'm с использованием приложения Spring Multi Module в Jboss EAP со всеми банками зависимостей в модуле Jboss (общая библиотека):
<dependencies>
<module name="com.etcbase.sharedlib" slot="4.3.14" export="true" meta-inf="export" />
<module name="org.jboss.jts" />
</dependencies>
Наряду с этим я использую Hotswap-Agent , который использует пружинный объект для своей функциональности, как в следующем методе создания прокси-пружины для горячей замены:
private Method getProxyCreationMethod(Object bean) throws CannotCompileException, NotFoundException {
if (getCp(loader).find("org.springframework.cglib.proxy.MethodInterceptor") != null) {
if (createSpringProxy == null) {
synchronized (springLock) {
if (createSpringProxy == null) {
ClassPool cp = getCp(loader);
springCallback = buildProxyCallbackClass(SPRING_PACKAGE, cp);
springNamingPolicy = buildNamingPolicyClass(SPRING_PACKAGE, cp);
springProxy = buildProxyCreaterClass(SPRING_PACKAGE, springCallback, springNamingPolicy, cp);
createSpringProxy = springProxy.getDeclaredMethods()[0];
}
}
}
return createSpringProxy;
Теперь, после создания SpringProxy, он использует его для следующих целей:Отражение Java:
private Object doCreate(Object beanFactry, Object bean, Class<?>[] paramClasses, Object[] paramValues) {
try {
Method proxyCreater = getProxyCreationMethod(bean);
if (proxyCreater == null) {
return bean;
} else {
return proxyCreater.invoke(null,beanFactry, bean, paramClasses, paramValues);
}
} catch (IllegalArgumentException | InvocationTargetException e) {
LOGGER.warning("Can't create proxy for " + bean.getClass().getSuperclass()
+ " because there is no default constructor,"
+ " which means your non-singleton bean created before won't get rewired with new props when update class.");
return bean;
} catch (IllegalAccessException | CannotCompileException | NotFoundException e) {
LOGGER.error("Creating a proxy failed", e);
throw new RuntimeException(e);
}
}
Таким образом, после того, как proxyCreater (из метода SpringProxy) пытается использовать функциональность invoke.Затем он генерирует исключение InvocationTargetException и печатает предупреждение о том, что он не сможет выполнить горячую замену компонентов, поскольку для него нет конструктора по умолчанию.
Проблема :Основная причина проблемы после отладки:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.objenesis.instantiator.util.UnsafeUtils
Полный журнал отладки сверху:
HOTSWAP AGENT: 10:49:35.672 ERROR (org.hotswap.agent.plugin.spring.getbean.EnhancerProxyCreater) - Can't create proxy for class com.etcbase.sfc.util.IdManagerImpl because there is no default constructor, which means your non-singleton bean created before won't get rewired with new props when update class.
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) HOTSWAP AGENT: 10:49:35.673 WARNING (org.hotswap.agent.plugin.spring.getbean.EnhancerProxyCreater) - error
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) java.lang.reflect.InvocationTargetException
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at java.lang.reflect.Method.invoke(Method.java:498)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.hotswap.agent.plugin.spring.getbean.EnhancerProxyCreater.doCreate(EnhancerProxyCreater.java:114)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.hotswap.agent.plugin.spring.getbean.EnhancerProxyCreater.create(EnhancerProxyCreater.java:83)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.hotswap.agent.plugin.spring.getbean.EnhancerProxyCreater.createProxy(EnhancerProxyCreater.java:79)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.hotswap.agent.plugin.spring.getbean.ProxyReplacer.register(ProxyReplacer.java:85)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1316)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1282)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
10:49:35,673 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
10:49:35,675 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
10:49:35,676 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:205)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:174)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:239)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:99)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
10:49:35,677 INFO [stdout] (ServerService Thread Pool -- 19) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at java.lang.Thread.run(Thread.java:748)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at org.jboss.threads.JBossThread.run(JBossThread.java:320)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) Caused by: org.springframework.objenesis.ObjenesisException: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.objenesis.instantiator.util.UnsafeUtils
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.objenesis.SpringObjenesis.newInstantiatorOf(SpringObjenesis.java:149)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.objenesis.SpringObjenesis.newInstance(SpringObjenesis.java:100)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at HotswapAgentSpringBeanProxy_1796692748.create(HotswapAgentSpringBeanProxy_1796692748.java)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) ... 92 more
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.objenesis.instantiator.util.UnsafeUtils
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.objenesis.instantiator.sun.UnsafeFactoryInstantiator.<init>(UnsafeFactoryInstantiator.java:43)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.objenesis.strategy.StdInstantiatorStrategy.newInstantiatorOf(StdInstantiatorStrategy.java:98)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) at org.springframework.objenesis.SpringObjenesis.newInstantiatorOf(SpringObjenesis.java:125)
10:49:35,678 INFO [stdout] (ServerService Thread Pool -- 19) ... 94 more
Из вышесказанного кажется, что утилиты spring obejenisis Unsafe не могут быть доступнытекущий загрузчик классов Jboss (который здесь кажется JbossModuleLoader), и кроме этого я проверил UnsafeUtils в соответствующем банке, который внутри модуля Jboss используется для всех jar.
Я свяжу проблему, которую ясоздан на GitHub, как это может помочь, но это все, что я мог знать.
Есть ли какой-нибудь способ найти unsafeutils через другой загрузчик классов или это другая проблема?
Github Проблема для этого