This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

parent= in xml causing NPE

Dec 1st, 2008, 11:18 AM

I have a bean declared in xml which uses parent="someotherbeanname". I have a top-level application-context that loads lots fo xml configs and some java configs. During the ConfigurationPostProcessor the BeanDefinition has a null class, which causes an NPE in ClassUtils.convertClassNameToResourcePath (stack below).

As I comment out the xml bean which declare a parent, the NPE moves on to the next bean with a parent. Is there some delayed configuration in spring-core related to bean with parent beans?

Code:

java.lang.NullPointerException
at org.springframework.util.ClassUtils.convertClassNameToResourcePath(ClassUtils.java:753)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:68)
at org.springframework.config.java.process.ConfigurationBeanDefinitionDecoratingBeanFactoryPostProcessor.isConfigClass(ConfigurationBeanDefinitionDecoratingBeanFactoryPostProcessor.java:63)
at org.springframework.config.java.process.ConfigurationBeanDefinitionDecoratingBeanFactoryPostProcessor.postProcessBeanFactory(ConfigurationBeanDefinitionDecoratingBeanFactoryPostProcessor.java:48)
at org.springframework.config.java.process.ConfigurationPostProcessor.postProcessBeanFactory(ConfigurationPostProcessor.java:42)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:554)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:363)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at com.its.infra.util.spring.BeanFactoryInstance$DefaultBeanFactoryInstantiator.newInstance(BeanFactoryInstance.java:104)
at com.its.infra.util.spring.BeanFactoryInstance.install(BeanFactoryInstance.java:85)
at com.its.infra.util.spring.BeanFactoryInstance.install(BeanFactoryInstance.java:52)
at com.its.infra.util.spring.BeanFactoryInstance.install(BeanFactoryInstance.java:48)
at test.ftest.trading.AbstractServerTestCase.setUpBeanFactoryInstance(AbstractServerTestCase.java:273)
at test.ftest.trading.AbstractServerTestCase.setUp(AbstractServerTestCase.java:243)
at com.its.importexport.FTestAccountElementSetImporter.setUp(FTestAccountElementSetImporter.java:40)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at test.support.BaseTestCase.run(BaseTestCase.java:53)
at test.support.AbstractTestCase.run(AbstractTestCase.java:88)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.junit.runners.Suite.runChild(Suite.java:115)
at org.junit.runners.Suite.runChild(Suite.java:23)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Comment

Hmm, I think I pasted the wrong stack trace. I was seeing this error only when the ConfigurationPostProcessor was executing. But the trace I did post has the error without ConfigurationPostProcessor, so maybe either way its a core issue.

I will need to create a simple test case in any case. If you want to can kill this thread and I will create another in core or just post jira issue.