Spring Boot: bean PlatformTransactionManager is overridden by FhirAutoConfiguration in HAPI FHIR 5.3.0

53 views
Skip to first unread message

Tyge Folke Nielsen

unread,
Feb 22, 2021, 8:19:25 AM2/22/21
to HAPI FHIR
Hi
We are upgrading from HAPI FHIR 5.0.2 to 5.3.0 and this is causing me some problems with Spring Boot.

We have a bean for PlatformTransactionManager to setup XA transactions with Atomikos.
When upgrading to HAPI FHIR 5.3.0 our bean is overridden by a bean defined in FhirAutoConfiguration (hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure) because this have been annotated with @Primary:

10:23:34.833 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Overriding bean definition for bean 'hapiTransactionManager' with a different definition: 
replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=true; factoryBeanName=terminologyServerConfig; factoryMethodName=hapiTransactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/systematic/ehealth/terminology/TerminologyServerConfig.class]] 
with [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=true; factoryBeanName=ca.uhn.fhir.spring.boot.autoconfigure.FhirAutoConfiguration$FhirJpaServerConfiguration$FhirJpaDaoConfiguration; factoryMethodName=hapiTransactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration$FhirJpaServerConfiguration$FhirJpaDaoConfiguration.class]]

Not beeing a Spring Boot expert I have had a hard time trying to fix this. 
I ended up by building a local version of HAPI-FHIR where I have removed the @Primary annotation (replaced with @ConditionalOnMissingBean).

Is there another way I can escape the @Primary annotation ?

Thank you,
- Tyge




ravikumar karuturi

unread,
Feb 24, 2021, 4:05:36 PM2/24/21
to HAPI FHIR
I'm also running into similar issue
Reply all
Reply to author
Forward
0 new messages