Announcement Announcement Module
Collapse
No announcement yet.
Custom XML Namespace Extension Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom XML Namespace Extension Problem

    I've written a fairly complex custom BeanDefinitionParser extended from AbstractBeanDefinitionParser. I followed the examples as closely as I could although they are fairly simple examples. The BeanDefinition that is returned to the Spring container consists of several nested bean definitions; some have Managed Maps of bean definitions. Based on the Component example is seamed that all beans need to be created with the BeanDefinitionBuilder and all lists and maps needed to be stored in ManagedList and ManagedMap. That is how I coded it. There is a good chance that I did something wrong. I coded up a simple JUnit test using the Spring test framework to test namespace. The junit test is defined as follows:
    {code}package gov.va.med.datasharing.audit.test.app.config;

    import gov.va.med.datasharing.common.service.config.app.A pplicationConfigManager;
    import gov.va.med.datasharing.common.test.CustomProfileVa lueSource;

    import java.util.List;

    import javax.annotation.Resource;

    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.test.annotation.ProfileValueSo urceConfiguration;
    import org.springframework.test.context.ContextConfigurat ion;
    import org.springframework.test.context.TestExecutionList eners;
    import org.springframework.test.context.junit4.SpringJUni t4ClassRunner;
    import org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener;
    import org.springframework.test.context.support.DirtiesCo ntextTestExecutionListener;

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = {
    "classpath:gov/va/med/datasharing/audit/test/context/auditConfigTest-context.xml",
    "classpath:schemaConfig-context.xml"
    })
    @TestExecutionListeners(value = {
    DependencyInjectionTestExecutionListener.class,
    DirtiesContextTestExecutionListener.class })
    @ProfileValueSourceConfiguration(CustomProfileValu eSource.class)
    public class TestSpringSchemaAppConfig {

    private static String DISCRIMINATOR_NAME = "CHDR";

    @Resource(name = "applicationConfigManager")
    ApplicationConfigManager applicationConfigManager;

    @Test
    public void testApplicationConfigManager() throws Exception
    {
    List<String> dataModelTypes = this.applicationConfigManager.getDataModelTypes(DI SCRIMINATOR_NAME);
    for (String type: dataModelTypes)
    {
    System.out.println(type);
    }
    }

    }
    {code}
    Somewhere before the bean is returned from the container; these errors occur: Looks like an infinite loop of some kind... Can anyone give me any clues to what I should look for to solve this issue?
    Thanks in advance.

    {code}14:12:49,000 ERROR [TestContextManager] Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener@1a0d866] to prepare test instance [gov.va.med.datasharing.audit.test.app.config.TestS pringSchemaAppConfig@19a37a]
    java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:308)
    at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.injectDependencies (DependencyInjectionTestExecutionListener.java:109 )
    at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.prepareTestInstanc e(DependencyInjectionTestExecutionListener.java:75 )
    at org.springframework.test.context.TestContextManage r.prepareTestInstance(TestContextManager.java:321)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.createTest(SpringJUnit4ClassRunner.j ava:220)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner$1.runReflectiveCall(SpringJUnit4Clas sRunner.java:301)
    at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.methodBlock(SpringJUnit4ClassRunner. java:303)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:240)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
    at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:180 )
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'applicaitonConfigManager': Initialization of bean failed; nested exception is java.lang.StackOverflowError
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:84)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:1)
    at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:280)
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:304)
    ... 24 more
    Caused by: java.lang.StackOverflowError
    at java.lang.Class.privateGetDeclaredFields(Class.jav a:2278)
    at java.lang.Class.getDeclaredFields(Class.java:1743)
    at org.springframework.util.ReflectionUtils.findField (ReflectionUtils.java:69)
    at org.springframework.util.ReflectionUtils.findField (ReflectionUtils.java:52)
    at org.springframework.core.convert.support.PropertyT ypeDescriptor.getAnnotations(PropertyTypeDescripto r.java:82)
    at org.springframework.core.convert.TypeDescriptor.to String(TypeDescriptor.java:466)
    at java.lang.String.valueOf(String.java:2826)
    at java.lang.StringBuilder.append(StringBuilder.java: 115)
    at org.springframework.core.convert.TypeDescriptor.to String(TypeDescriptor.java:472)
    at java.lang.String.valueOf(String.java:2826)
    at java.lang.StringBuilder.append(StringBuilder.java: 115)
    {code}

  • #2
    Custom XML Namespace Extension Problem

    I commented out most of the code and got it to work. So I'll gradually add the code back and find the problem. I'll post the result if I discover anything interesting. This could be the most complicated namespace ever attempted by a novice...

    Comment


    • #3
      Custom XML Namespace Extension Problem

      The problem shows up when addPropertyValue is called to set a map declared as follows.
      [code] ManagedMap<String, ManagedMap<String, BeanDefinition>> appConfigMap = new ManagedMap<String, ManagedMap<String, BeanDefinition>>();
      [code]

      Comment

      Working...
      X