org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name '' defined in class path resource [appContext.xml]: Child bean definition has neither 'id' nor 'name'

Spring JIRA | Dino | 1 decade ago
  1. 0

    Should not need to define an id for a bean if it has a parent attribute (if the parent attribute is not used then the bean does not require the id attribute). Here is the xml file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- This is ok --> <bean name="whatever" class="test"/> <bean name="two" parent="whatever" /> <!-- This is ok --> <bean class="test"/> <!-- named implicitly as test --> <bean class="test"/> <!-- named implicitly as test#2 --> <bean class="test"/> <!-- named implicitly as test#3 --> <!-- This is ok --> <bean name="whatever" class="test"/> <bean name="aname" parent="whatever" /> <!-- This is not ok --> <bean name="whatever2" class="test"/> <bean parent="whatever2" /> <!-- Generates the following exception org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name '' defined in class path resource [appContext.xml]: Child bean definition has neither 'id' nor 'name' at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition(DefaultXmlBeanDefinitionParser.java:277) at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinition(DefaultXmlBeanDefinitionParser.java:229) at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(DefaultXmlBeanDefinitionParser.java:180) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:164) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:128) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:124) at org.springframework.context.support.AbstractXmlApplicationContext.refreshBeanFactory(AbstractXmlApplicationContext.java:64) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:239) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56) at test.main(test.java:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78) --> </beans>

    Spring JIRA | 1 decade ago | Dino
    org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name '' defined in class path resource [appContext.xml]: Child bean definition has neither 'id' nor 'name'
  2. 0

    Should not need to define an id for a bean if it has a parent attribute (if the parent attribute is not used then the bean does not require the id attribute). Here is the xml file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- This is ok --> <bean name="whatever" class="test"/> <bean name="two" parent="whatever" /> <!-- This is ok --> <bean class="test"/> <!-- named implicitly as test --> <bean class="test"/> <!-- named implicitly as test#2 --> <bean class="test"/> <!-- named implicitly as test#3 --> <!-- This is ok --> <bean name="whatever" class="test"/> <bean name="aname" parent="whatever" /> <!-- This is not ok --> <bean name="whatever2" class="test"/> <bean parent="whatever2" /> <!-- Generates the following exception org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name '' defined in class path resource [appContext.xml]: Child bean definition has neither 'id' nor 'name' at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition(DefaultXmlBeanDefinitionParser.java:277) at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinition(DefaultXmlBeanDefinitionParser.java:229) at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(DefaultXmlBeanDefinitionParser.java:180) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:164) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:128) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:124) at org.springframework.context.support.AbstractXmlApplicationContext.refreshBeanFactory(AbstractXmlApplicationContext.java:64) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:239) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56) at test.main(test.java:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78) --> </beans>

    Spring JIRA | 1 decade ago | Dino
    org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name '' defined in class path resource [appContext.xml]: Child bean definition has neither 'id' nor 'name'
  3. 0

    How to access Spring context from a depending project?

    Stack Overflow | 3 years ago | Edmond
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [context.xml]; nested exception is java.io.FileNotFoundException: class path resource [context.xml] cannot be opened because it does not exist
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JBoss 4.2 load javax.xml.parsers.DocumentBuilderFactory from xmlparserv2.jar?

    Stack Overflow | 3 years ago | Viv
    org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/classes/conf/applicationContext.xml]; nested exception is java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
  6. 0

    Grails deployment to Glassfish and slf4j

    Stack Overflow | 4 years ago | tsure
    org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is **java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V**

    6 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.beans.factory.BeanDefinitionStoreException

      Error registering bean with name '' defined in class path resource [appContext.xml]: Child bean definition has neither 'id' nor 'name'

      at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition()
    2. Spring Beans
      XmlBeanDefinitionReader.loadBeanDefinitions
      1. org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition(DefaultXmlBeanDefinitionParser.java:277)
      2. org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinition(DefaultXmlBeanDefinitionParser.java:229)
      3. org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(DefaultXmlBeanDefinitionParser.java:180)
      4. org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:164)
      5. org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:128)
      5 frames
    3. Spring Context
      ClassPathXmlApplicationContext.<init>
      1. org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:124)
      2. org.springframework.context.support.AbstractXmlApplicationContext.refreshBeanFactory(AbstractXmlApplicationContext.java:64)
      3. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:239)
      4. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
      5. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
      6. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56)
      6 frames
    4. Unknown
      test.main
      1. test.main(test.java:13)
      1 frame
    5. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:324)
      4 frames
    6. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
      1 frame