java.lang.IllegalArgumentException: Cannot merge with object of type [class org.springframework.beans.factory.config.BeanDefinitionHolder]

Spring JIRA | Sam Brannen | 7 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Section _C.2.2.4 <util:list/>_ of the reference manual states: {quote}Finally, you can also control the merging behavior using the 'merge' attribute of the <util:list/> element; collection merging is described in more detail in the section called "Collection merging".{quote} This is, however, not true. In contrast to the standard support for collections (i.e., array, list, set, map) in the _beans_ namespace, the _util_ namespace does not support the merge attribute for collections. Is this an oversight in the documentation or missing functionality in the util namespace support? On a related note (perhaps worthy of its own JIRA issue), given the following application context configuration and JUnit test class... {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> <bean id="listHolderParent" class="com.example.MergedListTests$ListHolder" abstract="true"> <property name="list"> <list> <value>red</value> <value>green</value> <value>blue</value> </list> </property> </bean> <bean id="listHolder" parent="listHolderParent"> <property name="list"> <list merge="true"> <value>cyan</value> <value>magenta</value> <value>yellow</value> <value>black</value> </list> </property> </bean> </beans> {code} {code} package com.example; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.List; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MergedListTests { @Test public void mergedList() { ApplicationContext appCtx = new ClassPathXmlApplicationContext( "/com/example/MergedListTests-context.xml"); ListHolder listHolder = appCtx.getBean("listHolder", ListHolder.class); assertNotNull(listHolder); assertEquals(7, listHolder.getList().size()); } public static class ListHolder { private List<String> list; public List<String> getList() { return this.list; } public void setList(List<String> list) { this.list = list; } } } {code} ... changing the *<list>* definition in _listHolderParent_ to *<util:list>* results in the following exception: {quote} java.lang.IllegalArgumentException: Cannot merge with object of type [class org.springframework.beans.factory.config.BeanDefinitionHolder] at org.springframework.beans.factory.support.ManagedList.merge(ManagedList.java:98) at org.springframework.beans.factory.support.ManagedList.merge(ManagedList.java:1) at org.springframework.beans.MutablePropertyValues.mergeIfRequired(MutablePropertyValues.java:221) at org.springframework.beans.MutablePropertyValues.addPropertyValue(MutablePropertyValues.java:169) at org.springframework.beans.MutablePropertyValues.addPropertyValues(MutablePropertyValues.java:138) at org.springframework.beans.factory.support.AbstractBeanDefinition.overrideFrom(AbstractBeanDefinition.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1114) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1054) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1040) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:294) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:578) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:398) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.example.MergedListTests.mergedList(MergedListTests.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ...{quote}

    Spring JIRA | 7 years ago | Sam Brannen
    java.lang.IllegalArgumentException: Cannot merge with object of type [class org.springframework.beans.factory.config.BeanDefinitionHolder]
  2. 0

    Section _C.2.2.4 <util:list/>_ of the reference manual states: {quote}Finally, you can also control the merging behavior using the 'merge' attribute of the <util:list/> element; collection merging is described in more detail in the section called "Collection merging".{quote} This is, however, not true. In contrast to the standard support for collections (i.e., array, list, set, map) in the _beans_ namespace, the _util_ namespace does not support the merge attribute for collections. Is this an oversight in the documentation or missing functionality in the util namespace support? On a related note (perhaps worthy of its own JIRA issue), given the following application context configuration and JUnit test class... {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> <bean id="listHolderParent" class="com.example.MergedListTests$ListHolder" abstract="true"> <property name="list"> <list> <value>red</value> <value>green</value> <value>blue</value> </list> </property> </bean> <bean id="listHolder" parent="listHolderParent"> <property name="list"> <list merge="true"> <value>cyan</value> <value>magenta</value> <value>yellow</value> <value>black</value> </list> </property> </bean> </beans> {code} {code} package com.example; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.List; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MergedListTests { @Test public void mergedList() { ApplicationContext appCtx = new ClassPathXmlApplicationContext( "/com/example/MergedListTests-context.xml"); ListHolder listHolder = appCtx.getBean("listHolder", ListHolder.class); assertNotNull(listHolder); assertEquals(7, listHolder.getList().size()); } public static class ListHolder { private List<String> list; public List<String> getList() { return this.list; } public void setList(List<String> list) { this.list = list; } } } {code} ... changing the *<list>* definition in _listHolderParent_ to *<util:list>* results in the following exception: {quote} java.lang.IllegalArgumentException: Cannot merge with object of type [class org.springframework.beans.factory.config.BeanDefinitionHolder] at org.springframework.beans.factory.support.ManagedList.merge(ManagedList.java:98) at org.springframework.beans.factory.support.ManagedList.merge(ManagedList.java:1) at org.springframework.beans.MutablePropertyValues.mergeIfRequired(MutablePropertyValues.java:221) at org.springframework.beans.MutablePropertyValues.addPropertyValue(MutablePropertyValues.java:169) at org.springframework.beans.MutablePropertyValues.addPropertyValues(MutablePropertyValues.java:138) at org.springframework.beans.factory.support.AbstractBeanDefinition.overrideFrom(AbstractBeanDefinition.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1114) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1054) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1040) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:294) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:578) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:398) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.example.MergedListTests.mergedList(MergedListTests.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ...{quote}

    Spring JIRA | 7 years ago | Sam Brannen
    java.lang.IllegalArgumentException: Cannot merge with object of type [class org.springframework.beans.factory.config.BeanDefinitionHolder]
  3. 0

    Cluster / Node Manager « WebLogic

    middlewaremagic.com | 10 months ago
    org.apache.cxf.interceptor.Fault: argument type mismatch while invoking public com.nsn.see.application.callerid.Registration com.nsn.see.application.callerid.CallerIdService.registration(com.nsn.see.application.callerid.Register) with params [com.nsn.see.application.callerid.Register@1d03015d].
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Polymorphic Deserialization - object is not an instance of declaring class - Jackson JSON User Group

    ning.com | 11 months ago
    com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing property 'data' (expected type: [simple type, class java.lang.Object]; actual type: ItemTest$Device), problem: object is not an instance of declaring class (through reference chain: java.util.ArrayList[0])
  6. 0

    Works both for me, but not together: Encountered an error executing the step: class java.lang.IllegalArgumentException: Unable to invoke method: [public void XXXReader.beforeStep(org.springframework.batch.core.StepExecution)] on object: [XXXReader@8b567c] with arguments: [[StepExecution: id=0, name=writeDatasheetXml, status=STARTED, exitStatus=EXECUTING, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, commitCount=0, rollbackCount=0, exitDescription=]] java.lang.IllegalArgumentException: Unable to invoke method: [public void XXXReader.beforeStep(org.springframework.batch.core.StepExecution)] on object: [XXXReader@8b567c] with arguments: [[StepExecution: id=0, name=XXX, status=STARTED, exitStatus=EXECUTING, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, commitCount=0, rollbackCount=0, exitDescription=]] at org.springframework.batch.support.SimpleMethodInvoker.invokeMethod(SimpleMethodInvoker.java:97) at org.springframework.batch.core.listener.MethodInvokerMethodInterceptor.invoke(MethodInvokerMethodInterceptor.java:68) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy18.beforeStep(Unknown Source) at org.springframework.batch.core.listener.CompositeStepExecutionListener.beforeStep(CompositeStepExecutionListener.java:76) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:193) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348) at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43) at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:105) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:250) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:110) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:105) at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:207) at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:254) Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.batch.support.SimpleMethodInvoker.invokeMethod(SimpleMethodInvoker.java:95) ... 19 more

    Spring JIRA | 8 years ago | Jörg Gottschling
    java.lang.IllegalArgumentException: Unable to invoke method: [public void XXXReader.beforeStep(org.springframework.batch.core.StepExecution)] on object: [XXXReader@8b567c] with arguments: [[StepExecution: id=0, name=XXX, status=STARTED, exitStatus=EXECUTING, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, commitCount=0, rollbackCount=0, exitDescription=]]

    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. java.lang.IllegalArgumentException

      Cannot merge with object of type [class org.springframework.beans.factory.config.BeanDefinitionHolder]

      at org.springframework.beans.factory.support.ManagedList.merge()
    2. Spring Beans
      DefaultListableBeanFactory.getBeanNamesForType
      1. org.springframework.beans.factory.support.ManagedList.merge(ManagedList.java:98)
      2. org.springframework.beans.factory.support.ManagedList.merge(ManagedList.java:1)
      3. org.springframework.beans.MutablePropertyValues.mergeIfRequired(MutablePropertyValues.java:221)
      4. org.springframework.beans.MutablePropertyValues.addPropertyValue(MutablePropertyValues.java:169)
      5. org.springframework.beans.MutablePropertyValues.addPropertyValues(MutablePropertyValues.java:138)
      6. org.springframework.beans.factory.support.AbstractBeanDefinition.overrideFrom(AbstractBeanDefinition.java:300)
      7. org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1114)
      8. org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1054)
      9. org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1040)
      10. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:294)
      10 frames
    3. Spring Context
      ClassPathXmlApplicationContext.<init>
      1. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:578)
      2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:398)
      3. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
      4. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
      4 frames
    4. com.example
      MergedListTests.mergedList
      1. com.example.MergedListTests.mergedList(MergedListTests.java:17)
      1 frame
    5. Java RT
      NativeMethodAccessorImpl.invoke0
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      1 frame