-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Description
Alexander Fedorov opened SPR-7956 and commented
Exception after registerBeanDefinition:
13:22:38.758 [Thread-26] ERROR o.s.web.context.ContextLoader - Context initialization failed
java.util.ConcurrentModificationException: null
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372) ~[na:1.6.0_22]
at java.util.AbstractList$Itr.next(AbstractList.java:343) ~[na:1.6.0_22]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:559) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) ~[spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) ~[spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) ~[spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) ~[spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4521) [catalina.jar:7.0.6]
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5004) [catalina.jar:7.0.6]
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:4999) [catalina.jar:7.0.6]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_22]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_22]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_22]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_22]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_22]
How to repeat:
@Controller
public class PagesController
{
@Autowired
protected ApplicationContext context;
@PostConstruct
public void postConstruct()
{
String beanName = "testBean";
ConfigurableApplicationContext configContext = (ConfigurableApplicationContext) context;
AutowireCapableBeanFactory beanFactory = configContext.getBeanFactory();
BeanDefinitionRegistry registry = ((BeanDefinitionRegistry) beanFactory);
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(DefaultImpl.class);
beanDefinition.setLazyInit(false);
beanDefinition.setAbstract(false);
beanDefinition.setAutowireCandidate(true);
registry.registerBeanDefinition(beanName, beanDefinition);
}
}
Or like this.
serviceFactory.getByEntry is same as postConstruct() in previous example.
@Controller
public class PagesController
{
protected DefaultService sampleService;
@Autowired
public void setService(ServiceFactory serviceFactory)
{
sampleService = serviceFactory.get("A");
}
}
public class DefaultImpl
{
private String Test;
public String getTest()
{
return Test;
}
public void setTest(String test)
{
Test = test;
}
}
Affects: 3.0.5
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug