16

I have the configuration like below:

batch:job id="reconciliationJob" job-repository="jobRepository" restartable="true"

and during application context startup I receive something like this in the log:

[INFO] [] [] Overriding bean definition for bean 'reconciliationJob': replacing [Generic bean: class [org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.batch.core.configuration.xml.JobParserJobFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]

How can I solve this overriding problem?

hbaderts
  • 14,136
  • 4
  • 41
  • 48
przodownikPracy
  • 547
  • 2
  • 5
  • 12

5 Answers5

7

I got the same error. My problem was that I marked the class with @Service then in one of the @Configuration classes I created a @Bean out of it with the same name as the class.

ScanQR
  • 3,740
  • 1
  • 13
  • 30
Lakatos Gyula
  • 3,949
  • 7
  • 35
  • 56
4

This happens when Spring parses the same applicationContext.xml twice.

This can happen when for example your have duplicate/overriding <context-param> imports in your WEB.xml.

To solve the issue leave only the root applicationContext.xml there and remove the children.

Babken Vardanyan
  • 14,090
  • 13
  • 68
  • 87
3

This is not an error, is only an [INFO] and is a substitution done by Spring; you can see something similar about "step" scoped beans.
For example, if you have a bean marked as

<bean id="myBean" class="path.to.beanClass" scope="step" />

this will be replaced by a bean with name scopedTarget.myBean.
Lookup at StepScope doc and source

Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69
  • 1
    Due to this duplicate bean definition, server wont start properly for few cases. It leads to bean creation exception - **Requested bean is currently in creation: Is there an unresolvable circular reference?** Reference : http://stackoverflow.com/questions/10008714/requested-bean-is-currently-in-creation-is-there-an-unresolvable-circular-refer Two reasons for this: 1. Circular dependency 2. Duplicate bean definition FYI @przodownikPracy – Paramesh Korrakuti Feb 20 '15 at 10:17
1

I experienced something similar and I just changed the name of the class and it worked. Still can't figure out why. I'll update if I understand it better.

But start with changing the bean's class name.

Avi
  • 21,182
  • 26
  • 82
  • 121
-2

I had a similar problem and I resolved it using dependency:analyze in run maven -> goals. I found unused dependencies in my pom and I removed the unused dependencies.

Note: take care when removing the dependencies because the result of dependency:analyze it is not secure .

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197