You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caused by: java.lang.IllegalStateException: org.springframework.web.context.support.GenericWebApplicationContext@3fb1549b has not been refreshed yet
at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1141)
at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1293)
at com.alibaba.spring.util.BeanUtils.getBeanNames(BeanUtils.java:153)
at com.alibaba.spring.util.BeanUtils.getBeanNames(BeanUtils.java:136)
at com.alibaba.nacos.spring.util.NacosBeanUtils.isBeanDefinitionPresent(NacosBeanUtils.java:207)
at com.alibaba.nacos.spring.util.NacosBeanUtils.registerInfrastructureBeanIfAbsent(NacosBeanUtils.java:174)
at com.alibaba.nacos.spring.util.NacosBeanUtils.registerNacosApplicationContextHolder(NacosBeanUtils.java:285)
at com.alibaba.nacos.spring.util.NacosBeanUtils.registerNacosCommonBeans(NacosBeanUtils.java:372)
at com.alibaba.nacos.spring.context.annotation.NacosBeanDefinitionRegistrar.registerNacosAnnotationBeans(NacosBeanDefinitionRegistrar.java:83)
at com.alibaba.nacos.spring.context.config.xml.NacosAnnotationDrivenBeanDefinitionParser.parse(NacosAnnotationDrivenBeanDefinitionParser.java:49)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1391)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1371)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:179)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:149)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:96)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:511)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
... 37 more
Describe what you expected to happen
How to reproduce it (as minimally and precisely as possible)
Issue Description
Type: bug report
junit单元测试报错
Caused by: java.lang.IllegalStateException: org.springframework.web.context.support.GenericWebApplicationContext@3fb1549b has not been refreshed yet
at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1141)
at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1293)
at com.alibaba.spring.util.BeanUtils.getBeanNames(BeanUtils.java:153)
at com.alibaba.spring.util.BeanUtils.getBeanNames(BeanUtils.java:136)
at com.alibaba.nacos.spring.util.NacosBeanUtils.isBeanDefinitionPresent(NacosBeanUtils.java:207)
at com.alibaba.nacos.spring.util.NacosBeanUtils.registerInfrastructureBeanIfAbsent(NacosBeanUtils.java:174)
at com.alibaba.nacos.spring.util.NacosBeanUtils.registerNacosApplicationContextHolder(NacosBeanUtils.java:285)
at com.alibaba.nacos.spring.util.NacosBeanUtils.registerNacosCommonBeans(NacosBeanUtils.java:372)
at com.alibaba.nacos.spring.context.annotation.NacosBeanDefinitionRegistrar.registerNacosAnnotationBeans(NacosBeanDefinitionRegistrar.java:83)
at com.alibaba.nacos.spring.context.config.xml.NacosAnnotationDrivenBeanDefinitionParser.parse(NacosAnnotationDrivenBeanDefinitionParser.java:49)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1391)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1371)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:179)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:149)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:96)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:511)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
... 37 more
Describe what you expected to happen
How to reproduce it (as minimally and precisely as possible)
1.spring.xml 中 import nacos配置
}
随便自动注入个服务,然后test方法中调用自动注入服务方法即可
Tell us your environment
spring版本5.3.6
nacos-spring-context版本1.1.0
Anything else we need to know?
对比了一下spring事务注解解析的代码发现不同之处在于
NacosBeanUtils中
public static void registerInfrastructureBeanIfAbsent(BeanDefinitionRegistry registry,
String beanName, Class beanClass, Object... constructorArgs) { if (!isBeanDefinitionPresent(registry, beanName, beanClass) && !registry.containsBeanDefinition(beanName)) { registerInfrastructureBean(registry, beanName, beanClass, constructorArgs); } } 如上方法在判断是否已注册过bean的时候多了isBeanDefinitionPresent(registry, beanName, beanClass)的判断调用, 而其实现最终会调用AbstractApplicationContext的方法 public String[] getBeanNamesForType(@nullable Class type, boolean includeNonSingletons, boolean allowEagerInit) {
assertBeanFactoryActive();
return getBeanFactory().getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
}
此方法中assertBeanFactoryActive()抛出异常,ApplicationContext此时还未执行refresh方法并未激活
The text was updated successfully, but these errors were encountered: