Configuration problem: 'bean' or 'parent' is required for <ref> element
search cancel

Configuration problem: 'bean' or 'parent' is required for <ref> element

book

Article ID: 294393

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

Some customers implement VMware Gemfire security manager via Spring framework - they may meet the below exception when they start the locator by the below bean definition xml file.

Bean definition:
<bean id="appLog" class="com.sample.logging.FormattedLoggerImpl" init-method="initialize" depends-on="appLogConfiguration">
    <property name="logFileName"><value>gemfire-security.log</value></property>
    <property name="logLevel"><value>config</value></property>
    <property name="verboseLogging"><value>true</value></property>
    <property name="logConfiguration"><ref local="appLogConfiguration"/></property>
    <property name="maxLineLength"><value>4000</value></property>
    <property name="maxStackTrace"><value>true</value></property>   
    <property name="loggingMessages"><ref local="appMessages"/></property>
</bean>
 
<bean id="appLogConfiguration" class="com.sample.logging.LogConfigurationImpl">
    <property name="loggingDirectory"><value>gemfirelog</value></property>
    <property name="outputInitialLogRecords"><value>false</value></property>
</bean> 

Exception stack when starting locator:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unexpected failure during bean definition parsing 
Offending resource: class path resource [config/springContext.xml]

Bean 'appLog'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: 'bean' or 'parent' is required for <ref> element

Offending resource: class path resource [config/springContext.xml]
Property 'logConfiguration'
        -> Bean 'appLog'
        at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:119)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:288)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElement(BeanDefinitionParserDelegate.java:540)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElement(BeanDefinitionParserDelegate.java:437)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElement(BeanDefinitionParserDelegate.java:405)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinition(DefaultBeanDefinitionDocumentReader.java:306)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:197)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:176)
        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:514)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:394)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:337)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:305)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:224)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:195)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:257)
        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:128)
        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:94)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:133)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:637)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:522)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:95)
        at com.dtcc.cache.admin.security.IocBeanFactory.create(IocBeanFactory.java:23)
        at com.dtcc.cache.admin.security.DTCCSecurityManager.init(DTCCSecurityManager.java:56)
        at org.apache.geode.internal.security.CallbackInstantiator.getSecurityManager(CallbackInstantiator.java:67)
        at org.apache.geode.internal.security.SecurityServiceFactory.create(SecurityServiceFactory.java:60)
        at org.apache.geode.distributed.internal.InternalDistributedSystem.initialize(InternalDistributedSystem.java:692)
        at org.apache.geode.distributed.internal.InternalDistributedSystem.access$200(InternalDistributedSystem.java:135)
        at org.apache.geode.distributed.internal.InternalDistributedSystem$Builder.build(InternalDistributedSystem.java:3036)
        at org.apache.geode.distributed.internal.InternalDistributedSystem.connectInternal(InternalDistributedSystem.java:290)
        at org.apache.geode.distributed.internal.InternalLocator.startDistributedSystem(InternalLocator.java:741)
        at org.apache.geode.distributed.internal.InternalLocator.startLocator(InternalLocator.java:386)
        at org.apache.geode.distributed.LocatorLauncher.start(LocatorLauncher.java:714)
        at org.apache.geode.distributed.LocatorLauncher.run(LocatorLauncher.java:621)
        at org.apache.geode.distributed.LocatorLauncher.main(LocatorLauncher.java:215)
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: 'bean' or 'parent' is required for <ref> element

Offending resource: class path resource [config/springContext.xml]
Property 'logConfiguration'
        -> Bean 'appLog'
        at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:119)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:111)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parsePropertySubElement(BeanDefinitionParserDelegate.java:1003)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parsePropertySubElement(BeanDefinitionParserDelegate.java:971)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parsePropertyValue(BeanDefinitionParserDelegate.java:954)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parsePropertyElement(BeanDefinitionParserDelegate.java:851)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parsePropertyElements(BeanDefinitionParserDelegate.java:712)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElement(BeanDefinitionParserDelegate.java:525)
        ... 35 more


Environment

Product Version: 9.10

Resolution

In customer's Bean definition xml file, there are two major possibilities which could cause this kind of exception:

1. Since VMware Gemfire 9.10, Gemfire starts to certify with Spring framework 5.2.1 where the local attribute on the ref element is no longer supported any more in Spring framework 5.x. Regarding to this cause, customer needs to resolve this issue by using:
<ref bean="someBean"/>
instead of :
<ref local="someBean"/>
From the above exception stack, this should be the exact case which could cause this exception.

2. We also have some customers who resolved this kind of similar exception by using:
<property name="XXXX"><value>YYYY</value></property>
instead of:
<property name="XXXX" value="YYYY" />
This is just for your reference in case the above 1. doesn't help resolve your issue.